SharePoint Online: Get All Fields from List View using PowerShell
Requirement: Get all fields from a SharePoint Online List View
SharePoint Online: PowerShell to Get All Fields from a List View
This PowerShell script gets all fields from a given list view in SharePoint Online.
SharePoint Online: PowerShell to Get All Fields from a List View
This PowerShell script gets all fields from a given list view in SharePoint Online.
#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" #Config Parameters $SiteURL= "https://crescent.sharepoint.com/" $ListName="Projects" $ViewTitle ="All Items" #Setup Credentials to connect $Cred = Get-Credential $Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password) Try { #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Ctx.Credentials = $Cred #Get the List $List=$Ctx.Web.Lists.GetByTitle($ListName) #Get the List View $ListView = $List.views.GetByTitle($ViewTitle) $Ctx.load($ListView) $Ctx.executeQuery() #Get all fields from the list view $ViewFields= $ListView.ViewFields $Ctx.Load($ViewFields) $Ctx.ExecuteQuery() #Loop through all the fields of the view ForEach($ViewField in $ViewFields) { #Get the Field Name Write-Host $ViewField } } Catch { write-host -f Red "Error Getting List View Fields!" $_.Exception.Message }
No comments:
Please Login and comment to get your questions answered!