1 min readGet SharePoint Online list experience in site collection using PowerShell

1 min readGet 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.

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

Migrate Everything to Microsoft 365

Exchange Online SharePoint Online OneDrive For Business Microsoft Teams Microsoft Planner Viva Engage (Yammer) Microsoft Bookings Microsoft Forms Power Automate Microsoft Power BI Exchange Online SharePoint Online OneDrive For Business Microsoft Teams Microsoft Planner Viva Engage (Yammer) Microsoft Bookings Microsoft Forms Power Automate Microsoft Power BI
  • No Data Loss
  • Zero Downtime
  • ISO-Certified Protection

Start your free 15-days trial today !


4.5 out of 5