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 to the List settings page.
SharePoint Online: PowerShell to Get List Properties
You can get the list properties of a SharePoint Online list using this PowerShell script. All you need to do is open PowerShell and connect to your SharePoint Online site. Then, use the following script to get list properties:
#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
}
Use this script to get all properties from the list:
$List | select -Property *
This command will return a list of all properties for the list. 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!
PnP PowerShell to Get List Properties
Another approach is to use the Get-PnPList cmdlet. You must first connect to SharePoint Online using the Connect-PnPOnline cmdlet to use this cmdlet. Once you have connected, you can run the Get-PnPList cmdlet and specify the Name of the list you want to get information about.
PnP PowerShell can be used to retrieve list properties, including the URL, title, description, Item count, etc. For example, to get the number of items in a list, use the command Get-PnPList -Identity | Select ItemCount. Be sure to replace it with the actual name of the list.
#Set Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Marketing"
$ListName = "Announcements"
#Connect to SharePoint Online site
Connect-PnPOnline -Url $SiteURL -Interactive
#Get List
$List = Get-PnPList -Identity $ListName
#Get List Properties
Write-host "Versioning Enabled:"$List.EnableVersioning
To get any property of the “collection” type, use the “includes” parameter. E.g.,
#Get the List with "Author" property
$List = Get-PnPList -Identity $ListName -Includes Author
Invoke-PnPQuery
#Get the Login ID of the user created the List
Write-host "List Author:"$List.Author.LoginName
To update list settings in SharePoint Online using PowerShell, use: How to Update SharePoint Online List Settings using PowerShell?
Can I get list properties with PnP PowerShell?