SharePoint Online: Get List Experience Settings using PowerShell

Requirement: Get List Experience Settings in SharePoint Online using PowerShell.

How to Get SharePoint Online List Experience?

Do you ever need to know the list experience settings applied in a SharePoint Online site? Maybe you’re troubleshooting an issue and had to confirm that the setting is configured as expected. Or, perhaps you’re curious about what list experience is configured for all lists and libraries. In any case, if you want to get the experience settings for SharePoint Online lists, I will show you how to audit them.

To get list experience configuration of a list or library in SharePoint Online,

  • Navigate to the list or library settings >> Click on the “Advanced Settings” link.
  • In the advanced settings page, under “List Experience”, you can get the list experience of the current list.
    sharepoint online list experience

Retrieve List Experience using PowerShell:

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking

#Set Parameters for Site URL and List Name
$SiteURL= "https://crescent.sharepoint.com/sites/marketing"
$ListName= "Documents"
 
#Setup Credentials to connect
$Cred = Get-Credential
 
Try {
    #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)
    $Ctx.Load($List)
    $Ctx.ExecuteQuery()

    #Get list Experience
    Write-host $List.ListExperienceOptions
}
Catch {
    write-host -f Red "Error Getting List Experience Settings!" $_.Exception.Message
}

PowerShell to Get List Experience Settings in SharePoint Online Site Collection

We wanted to audit list experience settings for all lists in a SharePoint Online site collection. Here is the PowerShell script to extract all list settings to a CSV file:

#Function to get list experience of all lists in a given web
Function Get-PnPListExperience($Web)
{
    Write-host "Processing Web:"$Web.URL -f Yellow
    Connect-PnPOnline -Url $Web.URL -Interactive

    #Get All Lists from Web and Iterate through - Exclude Hidden and Certain System lists
    $ExcludedLists = @("Form Templates", "Site Assets", "Style Library", "Site Pages", "Preservation Hold Library")
    $Lists =  Get-PnPList | Where {$_.Hidden -eq $False -and $_.Title -notin $ExcludedLists}
    ForEach($List in $Lists)
    {
        #Get List Experience
        $Global:ListExperience += New-Object PSObject -Property ([Ordered]@{
            'SiteURL' = $Web.URL
            'List Title' = $List.Title
            'URL' = $List.DefaultViewUrl
            'List Experience' = $List.ListExperienceOptions
        })
    }
}

#Parameters
$SiteURL ="https://crescent.sharepoint.com/sites/operations"
$CSVPath = "C:\Temp\ListExperience.csv"
$Global:ListExperience = @()
   
#Connect to PnP Online
Connect-PnPOnline -URL $SiteURL -Interactive

#Get All Webs in the site collection and Iterate through
$Webs = Get-PnPSubWeb -Recurse -IncludeRootWeb
ForEach($Web in $Webs)
{ 
    Get-PnPListExperience -Web $Web
}
#Export Data to CSV file
$Global:ListExperience | Sort-Object SiteURL
$Global:ListExperience | Sort-Object SiteURL | Export-csv -Path $CSVPath -NoTypeInformation

Report output:

powershell to get sharepoint online list experience

Here is my other post to set a list to modern experience: SharePoint Online: Change List Experience using PowerShell

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.