0

I am aware of the scripts Microsoft and others have provided to enable the new 'modern' experience/UI in SharePoint Online. When I run the below code, however, the experience does not change. I am testing by visiting the site contents page of the root web.

public static void EnableNewExperience(Web web, bool enableRootCollectionFeature)
{
    ClientContext ctx = (ClientContext)web.Context;
    Guid siteFeatureId = new Guid("E3540C7D-6BEA-403C-A224-1A12EAFEE4C4");
    ctx.Site.Features.Remove(siteFeatureId, true);
    ctx.ExecuteQuery();
}

2 Answers 2

0

I am using the following PowerShell to change between modern and classic experience. This is working as expected and tested site contents and libraries.

#Script to enable / disable modern experience to site collection

$host.Runspace.ThreadOptions = "ReuseThread"  

#Required Parameters 

$sSiteColUrl = "<<site collection url>>"  
$sUserName = "<<user name>>"  
$sPassword = Read-Host -Prompt "Enter your password: " -AsSecureString 
$featureId = "E3540C7D-6BEA-403C-A224-1A12EAFEE4C4"

try 
{     
    #Adding the Client OM Assemblies         
    Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" 
    Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" 

    #SPO Client Object Model Context 
    $spoCtx = New-Object Microsoft.SharePoint.Client.ClientContext($sSiteColUrl)  
    $spoCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($sUsername, $sPassword)   
    $spoCtx.Credentials = $spoCredentials       

    ##Change to modern experience
    $featureguidSite = [Guid]"E3540C7D-6BEA-403C-A224-1A12EAFEE4C4"
    $spoCtx.Site.Features.Remove($featureguidSite, $true);
    $spoCtx.ExecuteQuery();

    ##revert to classic experience
    <# 
    $spoCtx.Site.Features.Add($featureId, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None);
    $spoCtx.ExecuteQuery();
    #>

    $spoCtx.Dispose() 
} 
catch [System.Exception] 
{ 
    write-host -f red $_.Exception.ToString()    
}  
6
  • Thanks for the help. The ##Change to modern experience section in the code is exactly what I am doing in C# to no avail. Any idea why it wouldn't work? maybe some setting somewhere? Commented Jul 18, 2017 at 13:08
  • I have tested and worked without additional steps. Can you try from a different browser or clear cache? Commented Jul 18, 2017 at 13:33
  • I tried IE, Chrome, Firefox, and Edge and cleared cache, but this did not seem to affect it. Interesting thing is I am able to create a new page with the modern UI, but the site contents and each library continues to show the classic UI. I can get the libraries to work if I enable them in the advanced settings, but I'd rather not go library by library programmatically or manually, shouldn't it inherit from the site collection? Commented Jul 18, 2017 at 17:37
  • @KevinStone - Depending on the features that you have enabled on a doclib / list, you might default to the classic experience because you are using functionality that doesn't exist in the modern experience. If you create a plain doclib / list, do you still see a classic experience? Commented Jul 18, 2017 at 18:10
  • @PatMill_MSFT - Very good point, I had forgotten about that, but this is a brand-new site collection with no customization of any kind. For kicks, I created another site collection, and tried removing the feature. I got an error that the feature was not activated at that scope. I feel like I'm missing something obvious Commented Jul 20, 2017 at 17:45
0

The problem was that we needed to enable the modern UI globally via the SharePoint admin center first. Then we had to opt-out of the new experience using code on our site collections where we did not want it enabled by ADDING the feature with the GUID "E3540C7D-6BEA-403C-A224-1A12EAFEE4C4".

  1. We enabled the new experience globally in the SharePoint Admin center
  2. We then ENABLED the feature E3540C7D-6BEA-403C-A224-1A12EAFEE4C4 at the site collection level for site collections where we wanted to DISABLE the new, modern UI. This allowed us to opt-out of the new experience.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.