You may have noticed recently that your lists and libraries in SharePoint Online had changed from the Classic Experience to the Modern Experience. While Microsoft continues to push the use of the Modern Experience, these changes may become more frequent.
However, there are definitely some instances where you may want to remain on the Classic Experience for the time being, branding being one of the biggest reasons. Customization of any kind that was developed in Classic SharePoint using Content Editor Web Parts, Script Editor Web Parts, Master Page changes, etc. will not carry over into the modern sites.
The same applies to any sort of custom web parts that may have been developed for SharePoint. Any custom development that was not constructed using SharePoint Framework would not be supported or carry over easily.
So, here is a quick and easy way to use PnP PowerShell to revert all your lists and libraries back to Classic.
The Code to Revert Back to SharePoint Online Classic
The code we use is less than 40 lines and will return all the lists and libraries back to the way they were. The code does need to be run per site collection, as it will grab each subsite and their respective subsites under them and collect the lists and libraries to change back. If you are in an environment that tends to lean toward separate site collections for most aspects of your intranet, the script can be slightly modified to first grab all site collections (using and storing Get-PnPTenantSite in a variable while connected to your admin SharePoint center) and executing this same code in a loop through that variable. The code is as shown in the following screenshot.
The Process Behind the Code
The code shown will connect to your site collection via Connect-PnPOnline and the -UseWebLogin flag.
- First, while we are connected to the root web, we can grab all of its lists and store them in $rootLevelLists.
- Then, we loop through each list, check if it is already in Classic Experience and if not, use the Set-PnPList command to set it to “ClassicExperience”. You’ll notice we don’t have to use the -Web flag here as we are already in the context of where these lists live in the root.
- On line 3, we can gather all of the subsites under the root using Get-PnPSubWebs. The -Recurse flag will ensure we also get every subsite nested within a subsite.
- From there, we can iterate through each site, get and store all of the respective site’s lists in $subWebLists.
- We then iterate through each list, check if it is already in Classic Experience and if it is not, use the Set-PnPList command to set the List Experience to “ClassicExperience”.
The code could be refactored a bit and thrown into a function, but in this format it may be a bit easier to read. Depending on the amount of site collections, sites, lists, and libraries you have this could take 5-10+ minutes to run.
Once completed, all lists and libraries across your tenant should now be set to Classic Experience. Should you want to change this at any point in time, you can replace all of the “ClassicExperience” strings in the code to either “Auto” or “NewExperience” and re-run the script.
If you have any questions on this process or anything else related to SharePoint Online, let us know. We support literally everything SharePoint.