Powershell Script - Switch All lists and libraries back to Classic
-
07-02-2021 - |
Question
I hadn't opted out, I don't know how I missed the message about opting out but today all of our lists/libraries have switched over to modern.
I can no longer switch it back to classic in the admin center, and having to do it at the individual list/library level is going to be killer.
Is there any way that I can set all lists/libraries back to the classic experience using powershell?
I've been searching and looking but have found nothing. I found this article on here, but from the comments it looks like this does not work?
Solution
Refer below code :
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"
$webUrl = 'Enteryoursiteurl'
$username = Read-Host -Prompt "Enter User Name"
$password = Read-Host -Prompt "Password for $username" -AsSecureString
[Microsoft.SharePoint.Client.ClientContext]$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)
$clientContext.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
$web = $clientContext.web
$lists = $web.Lists
$clientContext.load($lists)
$clientContext.ExecuteQuery()
foreach($list in $lists){
# Set the list experience (0 = Auto, 1 = modern, 2 = classic)
$list.ListExperienceOptions = 2
$list.Update()
$clientContext.ExecuteQuery()
}
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange