1 min to read
Get SharePoint Online list experience in site collection using PowerShell
In this blog, we shall check how to get the experience type set for document libraries/lists in site collection using PowerShell. This script requires SharePoint Online PnP module, install it from here.
``` {.black .top-margin .bottom-margin}
function Get-ListExperience
{
Param(
[System.Management.Automation.PSCredential]$cred,
[String]$Sitecollection
)
Connect-PnPOnline -Url $Sitecollection -Credentials $cred
$Alldoc = @()
$Lists=Get-PnPList |Where-Object {$.Title -ne ‘Form Templates’ -and $.Title -ne ‘Site Assets’ -and $_.Title -ne ‘Style Library’}
foreach($List in $Lists)
{
$DocList = “” | Select “Title”,”Url”,”ListExperienceOptions”
$DocList.Title =$List.Title
$DocList.Url =($List.DefaultViewUrl -split “/Forms/AllItems.aspx”)[0]
$DocList.ListExperienceOptions =$List.ListExperienceOptions
$Alldoc+= $DocList
$DocList =$null
}
$subwebs=Get-PnPSubWebs -Recurse
foreach($subweb in $subwebs)
{
Connect-PnPOnline -Url $subweb.Url -Credentials $cred
$Lists= Get-PnPList |Where-Object {$_.Title -ne 'Form Templates' -and $_.Title -ne 'Site Assets' -and $_.Title -ne 'Style Library'}
foreach($List in $Lists)
{
$DocList = "" | Select "Title","Url","ListExperienceOptions"
$DocList.Title =$List.Title
$DocList.Url =($List.DefaultViewUrl -split "/Forms/AllItems.aspx")[0]
$DocList.ListExperienceOptions =$List.ListExperienceOptions
$Alldoc+=$DocList
$DocList=$null
}
}
$Alldoc } $Sitecollection = Read-Host -prompt "Enter the Site Collection URL: " $cred=Get-Credential Get-ListExperience -cred $cred -Sitecollection $Sitecollection
```
Result