PowerShell Script – CSOM – Enable Disable Modern UI and Classic UI in SharePoint Office 365


Sathish Nadarajan
SharePoint MVP
Published On :   05 Dec 2017
Visit Count
Today :  8    Total :   567
Plan, Migrate, Secure, Report
SharePoint & Office 365 Tool. Simple & Easy to Use. 15-Day Trial!

SharePoint Office 365 Tool
Simple & Powerful Tool for Migration, Security & Reporting. Free Trial


In this article, we can see a handy script to toggle between the Modern UI and Classic UI in SharePoint Office 365.

The default Modern UI of Site will be as below.

clip_image002

To enable the Classic View, we have a link on the left bottom.

clip_image003



The PowerShell Script to toggle between the Modern UI and the Classic UI is as below.

 # Add Necessary Client DLLs
 Add-Type -Path "C:\SATHISH\ARTICLES\ClientDLLs\Microsoft.SharePoint.Client.dll" 
 Add-Type -Path "C:\SATHISH\ARTICLES\ClientDLLs\Microsoft.SharePoint.Client.Runtime.dll" 
 
 #Get the UserName and Password
 $UserName = "sathish@*****.onmicrosoft.com"
 $password = Read-Host 'Enter Password' -AsSecureString
 $Url = "https://**********.sharepoint.com/sites/DeveloperSite/"
 $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName , $Password)
 
 $context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
 $context.Credentials = $credentials        
 
 #Get the Web Scoped Feature
 
 $web = $context.Web
 # Feature Title : EnableDefaultListLibrarExperience, Scope : Web
 $featureguid = new-object System.Guid "52E14B6F-B1BB-4969-B89B-C4FAA56745EF" 
 
 #To Enable/Disable the Modern UI, comment and uncomment the below two lines, either to Add or Remove
 #$web.Features.Add($featureguid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None)
 $web.Features.Remove($featureguid, $true)        
 
 $context.ExecuteQuery() 
 
  
 #Get the Site Scoped Feature
 $Site = $context.Site
 # Feature Title : EnableDefaultListLibrarExperience, Scope : Site
 $featureguid = new-object System.Guid "E3540C7D-6BEA-403C-A224-1A12EAFEE4C4" 
 
 #To Enable/Disable the Modern UI, comment and uncomment the below two lines, either to Add or Remove
 #$Site.Features.Add($featureguid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None)
 $Site.Features.Remove($featureguid, $true)        
 
 $context.ExecuteQuery()  
 


Happy Coding,

Sathish Nadarajan.

SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Categories

SharePoint Analytics