SharePoint Online: Get All Fields from a List View using PowerShell

Requirement: Get all fields from a SharePoint Online List View

How to Get Columns from a SharePoint Online View?

To view all columns included in a SharePoint Online list view, click on the little down-arrow next to any column in the view >> Choose Column Settings >> Show/hide columns.

get columns from view sharepoint online

You can also use: Edit current View to get fields included in the particular 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.

#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= ""
$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
    #Get the List View
    $ListView = $List.views.GetByTitle($ViewTitle)

    #Get all fields from the list view
    $ViewFields= $ListView.ViewFields

    #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

PnP PowerShell to Get All Columns from a SharePoint Online View:

$SiteURL = ""
$ListName = "Projects"
$ViewName = "Active Projects"

Try {
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -Interactive

    #Get the View
    $View = Get-PnPView -List $ListName -Identity $ViewName -Includes ViewFields
    #Get all Fields from the view - Internal Name
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

Your email address will not be published. Required fields are marked *