SharePoint Online: Get List Settings using PowerShell

Requirement: Get SharePoint Online list settings using PowerShell

How to Get List Properties in SharePoint Online?

To get list properties such as List Title, Description, Versioning Settings, Require Checkout, etc you can head on to List setting page.

sharepoint online powershell get list properties

SharePoint Online: PowerShell to Get List Properties

You can get list properties of a SharePoint Online list using this PowerShell script.

#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"
 
#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)
    $Ctx.Load($List)
    $Ctx.ExecuteQuery()
  
    #Get List Properties: Title, Description
    Write-host -f Yellow "---  General Settings ---"
    Write-host "List Title:" $List.Title
    Write-host "List Description:" $List.Description
    #Write-host "Show in Quick Launch:" $List.OnQuickLaunch

    Write-host -f Yellow "--- Versioning settings ---"
    Write-host "Content Approval Enabled:" $List.EnableModeration
    Write-host "Versioning Enabled:" $List.EnableVersioning
    Write-host "Major Versions Limit:" $List.MajorVersionLimit
    #Write-host "Minor Versions Enabled:" $List.EnableMinorVersions
    Write-host "Minor Versions Limit:" $List.MajorWithMinorVersionsLimit        
    Write-host "Draft Versions Security:" $List.DraftVersionVisibility
    Write-host "Require Checkout:" $List.ForceCheckout  #In Document Libraries

    Write-host -f Yellow "--- Advanced settings ---"
    Write-host "Content Type Enabled:"$List.ContentTypesEnabled
    Write-host "Attachments Enabled:"$List.EnableAttachments
    Write-host "New Folders Command Available:"$List.EnableFolderCreation
    Write-host "No Crawl Flag:"$List.NoCrawl
    #Write-host "Offline Availability:"$List.ExcludeFromOfflineClient
    Write-host "List Experience:"$List.ListExperienceOptions
    
    #Other hidden Settings
    Write-host -f Yellow "--- Other settings ---"
    Write-host "List ID:"$List.ID
    Write-host "List Created On:"$List.Created
    Write-host "Last Item Deleted On:"$List.LastItemDeletedDate 
    Write-host "Last Item Modified On:"$List.LastItemModifiedDate
    Write-host "List Item Count:"$List.ItemCount
    Write-host "Is Hidden List:"$List.Hidden
    Write-host "Document Template:"$List.DocumentTemplateUrl #In Document Libraries
    Write-host "List Type:"$List.BaseType   
    
}
Catch {
    write-host -f Red "Error Getting List Properties!" $_.Exception.Message
}

Please note, not all list properties can be retrieved or set through CSOM! Here is the One-liner to retrieve all available properties of a SharePoint Online list or library:

$List | Select -Property ([Microsoft.SharePoint.Client.List].GetProperties().Where({$_.Propertytype -notlike "*Collection"})).Name

We’ve filtered collection properties because any collection must be loaded explicitly first and then can be accessed!

To get all methods and properties available for a List object, You can use SharePoint Online Client Browser or this PowerShell code: $List | Get-member

PnP PowerShell to Get List Properties

#Set Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Marketing"
$ListName = "Announcements"

#Connect to SharePoint Online site
Connect-PnPOnline -Url $SiteURL -UseWebLogin

#Get List
$List = Get-PnPList -Identity $ListName
Invoke-PnPQuery

#Get List Properties
Write-host "Versioning Enabled:"$List.EnableVersioning

To get any property of “collection” type, use -Includes parameter. E.g.

#Get the List with "Author" property
$List = Get-PnPList -Identity $ListName -Includes Author
Invoke-PnPQuery

#Get Email of the user has created the List
Write-host "List Author:"$List.Author.Email

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!

One thought on “SharePoint Online: Get List Settings using PowerShell

  • April 9, 2020 at 7:24 PM

    Can I get list properties with PnP PowerShell?

    Reply

Leave a Reply