Change The Default Experience By Using Windows Power Shell

You may notice Microsoft slowly changing the list and document library look and feel from the classic to the new experience. This new experience is faster and has additional features for phone and tablet view. A document library or list owner, site owner, or admin can switch the default experience back to the previous  one (classic view).

There are three methods by which we can change the new experience to the classic experience. 

  • Change the experience for list/library from list settings.
  • Change the experience for all lists and libraries from tenant level (SharePoint admin center àSettings)
  • Change the experience at the site and site collection level by using PowerShell script.
In this article, we are going to see how to change the default experience at the site and site collection level by using Windows PowerShell Script.

Modules

  • Check for customization that affects list and library pages
  • Change the default experience for sites and site collections.

Check for customization that affects list and library pages

The following script detects the customization from sites and site collections.

Steps to follow

  •  You need Global Administrator permission.
  •  Copy the following code and paste it into a text editor, such as notepad. For this article, we will name the script file,  CustomAction.ps1.

CustomActions.Ps1

Add-Type -Path "C:\Users\<username>\downloads\Microsoft.SharePointOnline.CSOM.16.1.5026.1200\lib\net45\Microsoft.SharePoint.Client.dll"

Add-Type -Path "C:\Users\<username>\downloads\Microsoft.SharePointOnline.CSOM.16.1.5026.1200\lib\net45\Microsoft.SharePoint.Client.Runtime.dll"

  1. #All strings in braces < > are placeholders that you must replace with the appropriate strings.  
  2. $webUrl = 'https://<domain>.sharepoint.com/<relative-path-to-website>'  
  3. $username = '<username>@<domain>.onmicrosoft.com'  
  4. $password = Read - Host - Prompt "Password for $username" - AsSecureString[Microsoft.SharePoint.Client.ClientContext] $clientContext = New - Object Microsoft.SharePoint.Client.ClientContext($webUrl)  
  5. $clientContext.Credentials = New - Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)  
  6. $site = $clientContext.Site;  
  7. $customActions = $site.UserCustomActions  
  8. $clientContext.Load($customActions)  
  9. $clientContext.ExecuteQuery()  
  10. $first = $true  
  11. foreach($customAction in $customActions) {  
  12.     if ($customAction.Location - eq "scriptlink" - and - Not([string]::IsNullOrEmpty($customAction.ScriptBlock))) {  
  13.         if ($first) {  
  14.             Echo " "  
  15.             Echo($webUrl + " has the following inline JavaScript custom actions")  
  16.             $first = $false  
  17.         }  
  18.         Echo $customAction.Title  
  19.     }  
  20. }  

Save the file, naming it CustomActions.ps1.

Go to Window PowerShell prompt and Change the directory where you saved the file.

In PowerShell Command prompt type the below comment.

“./CustomAction.Ps1 “

Change the default experience for the sites and site collections

To change the default experience for library/lists on a site collection level, you must use a Windows PowerShell script with a CSOM (client -side object model).

Steps to follow

  •     You need Global Admin permission.
  •     Copy the below script and paste it in notepad. For this article, we will name the script file, DocLib.ps 

DocLib.ps1

  1. Add - Type - Path "C:\Users\{username}\downloads\Microsoft.SharePointOnline.CSOM.16.1.5026.1200\lib\net45\Microsoft.SharePoint.Client.dll"  
  2. Add - Type - Path "C:\Users\{username}\downloads\Microsoft.SharePointOnline.CSOM.16.1.5026.1200\lib\net45\Microsoft.SharePoint.Client.Runtime.dll"  
  3. $webUrl = 'https://{domain}.sharepoint.com/[optional path to subweb]'  
  4. $username = Read - Host - Prompt "Enter or paste the site collection administrator’s full O365 email, for example, [email protected]"  
  5. $password = Read - Host - Prompt "Password for $username" - AsSecureString[Microsoft.SharePoint.Client.ClientContext] $clientContext = New - Object Microsoft.SharePoint.Client.ClientContext($webUrl)  
  6. $clientContext.Credentials = New - Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)# To apply the script to the site collection level, uncomment the next two lines.#$site = $clientContext.Site;#  
  7. $featureguid = new - object System.Guid "E3540C7D-6BEA-403C-A224-1A12EAFEE4C4"  
  8. #To apply the script to the website level, uncomment the next two lines, and comment the preceding two lines.#$site = $clientContext.Web;  
  9. #$featureguid = new - object System.Guid "52E14B6F-B1BB-4969-B89B-C4FAA56745EF"  
  10. #To turn off the new UI by  
  11. default in the new site, uncomment the next line.#$site.Features.Add($featureguid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None);  
  12. #To re - enable the option to use the new UI after having first disabled it, uncomment the next line.#and comment the preceding line.#$site.Features.Remove($featureguid, $true);  
  13. $clientContext.ExecuteQuery();  

  • Save the file, naming it DocLib.ps1.
  • Go to Window PowerShell prompt and Change the directory where you saved the file.
  • In PowerShell Command prompt type the below comment.

      “./DocLib.Ps1 “

Keynotes

  • Check for customization that affects list and library pages
  • Change the default experience for sites and site collections.

Up Next
    Ebook Download
    View all
    Learn
    View all