Get List Fields in SharePoint using PowerShell

Requirement: Get all Fields from a SharePoint list using PowerShell.

PowerShell Script to get all List Fields, Internal Name, and Field types:

Let’s get the internal name of SharePoint list columns using PowerShell.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Configuration Parameters
$SiteURL="http://intranet.crescent.com/"
$ListName= "Quick Links"

#Get the List
$List = (Get-SPWeb $SiteURL).Lists.TryGetList($ListName)

Write-Host "Field Name | Internal Name | Type"
Write-Host "------------------------------------"

#Loop through each field in the list and get the Field Title, Internal Name and Type
ForEach ($Field in $List.Fields)
{
    Write-Host $Field.Title"|"$Field.internalName"|"$Field.Type
}  

This PowerShell script gets all column names, internal name and column types from the given SharePoint list!

sharepoint powershell get list columns

PowerShell to Export List Fields to a CSV File:

Let’s export all fields of a list into a CSV file using PowerShell.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Configuration Parameters
$SiteURL="http://intranet.crescent.com/"
$ListName= "Projects"
$CSVPath="C:\Temp\Fields.csv"

#Get the Web and List
$Web = Get-SPWeb $SiteURL
$List = $Web.Lists.TryGetList($ListName)

#Export List Fiels to CSV file
$List.Fields | select Title, InternalName | Export-Csv -path $CSVPath -NoTypeInformation

To get list fields in SharePoint Online, refer: SharePoint Online: Get List Fields using PowerShell

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

3 thoughts on “Get List Fields in SharePoint using PowerShell

  • October 7, 2018 at 10:40 AM

    Thank you! This was a great time-saver for me.

    Reply
  • June 25, 2018 at 2:19 PM

    Hi,
    How we can get the searchable columns list as a report like web application or sub site level? I searched the properties but not getting. Any suggestion!!

    Reply
  • March 29, 2018 at 7:52 AM

    Nice Post and Code.. it saved my Time

    Reply

Leave a Reply