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?
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
    #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 -Web $Web | 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/marketing"
$CSVPath = "C:\Temp\ListExperience.csv"
$Global:ListExperience = @()
   
#Connect to PnP Online
Connect-PnPOnline -URL $SiteURL -UseWebLogin
 
#Get the Root Web
$RootWeb = Get-PnPWeb

#Call the function for Root web
Get-PnPListExperience -Web $RootWeb

#Get All Webs in the site collection and Iterate through
$Webs = Get-PnPSubWebs -Recurse
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 list to modern experience: SharePoint Online: Change List Experience using PowerShell

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.