SharePoint Online: Get List Field Properties using PowerShell

Requirement: Get List Field Settings in SharePoint Online using PowerShell

SharePoint Online: PowerShell to Get Field Properties
This PowerShell script gets you the common properties from a SharePoint Online list field.
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#Set Config Parameters
$SiteURL="https://crescent.sharepoint.com/sites/projects"
$ListName="PMO Projects"
$FieldName="HeadCount" #Internal Name

#Get Credentials to connect
$Cred= Get-Credential

#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

#Get the List
$List=$Ctx.Web.Lists.GetByTitle($ListName)

#Get the List Field
$Field=$List.Fields.GetByInternalNameOrTitle($FieldInternalName)
$Ctx.Load($Field)
$Ctx.ExecuteQuery()

#Get List Field Settings
Write-host "Title:"$Field.Title
Write-host "Description:"$Field.Description
Write-host "Default Value:"$Field.DefaultValue
Write-host "Unique Values:"$Field.EnforceUniqueValues
Write-host "Is Hidden:"$Field.Hidden
Write-host "Field ID:"$Field.Id
Write-host "Indexed:"$Field.Indexed
Write-host "InternalName:"$Field.InternalName
Write-host "Required Field:"$Field.Required
Write-host "Sortable:"$Field.Sortable
Write-host "Filterable:"$Field.Filterable
Write-host "Type:"$Field.TypeAsString
Write-host "Type Display Name:"$Field.TypeDisplayName
Write-host "Sealed:"$Field.Sealed
Write-host "Can Be Deleted:"$Field.CanBeDeleted
Write-host "Read Only Field:"$Field.ReadOnlyField
Write-host "Group:"$Field.Group
Write-host "Field Scope:"$Field.Scope
Write-host "JSLink:"$Field.JSLink
Write-host "Schema XML:"$Field.SchemaXML
Write-host "Validation Formula:"$Field.ValidationFormula
Write-host "Validation Message:"$Field.ValidationMessage
SharePoint Online: Get List Field Properties using PowerShell SharePoint Online: Get List Field Properties using PowerShell Reviewed by Salaudeen Rajack on July 01, 2017 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.