Forum Discussion
Enable modern site pages
- Mar 16, 2017
I had the same problem. I had to activate the SitePage feature in the site settings (see attached pic)
Hi
Below powershell script worked for me.. I got it from microsoft technical team.
# Load SharePoint Online Client Components SDK Module
Import-Module 'C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll'
# Set script constants
$sitePagesFeatureIdString = 'B6917CB1-93A0-4B97-A84D-7CF49975D4EC'
# Set up client context
$userName = Read-Host "Username"
$password = Read-Host "Password" -AsSecureString
$siteUrl = Read-Host "Site Url"
$webUrl = Read-Host "Server-Relative Web Url"
$context = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $password)
$context.Credentials = $credentials
# Get the list of existing features
$web = $context.Site.OpenWeb($webUrl)
$features = $web.Features
$context.Load($features)
$context.ExecuteQuery()
# Verify that the Site Pages feature is not present in the web
if(($features | ? { $_.DefinitionId -eq $sitePagesFeatureIdString }).Count -gt 0)
{
Write-Host "The Site Pages feature is already enabled in this web"
return
}
# Add the Site Pages feature back to the web
$features.Add((new-object 'System.Guid' $sitePagesFeatureIdString), $false, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None)
$context.ExecuteQuery()
# Verify that the Site Pages feature is now present in the web
$web = $context.Site.OpenWeb($webUrl)
$features = $web.Features
$context.Load($features)
$context.ExecuteQuery()
if(($features | ? { $_.DefinitionId -eq $sitePagesFeatureIdString }).Count -gt 0)
{
Write-Host "The Site Pages feature has been successfully enabled"
}
else
{
throw "The Site Pages feature failed to be enabled"
}
Hi, from a functional perspective, what exactly does this script do? Does it enable a certain feature or does it directly make a specific site collection as root site collection ... ?
Thanks for your feedback!
- Rajashekhar SheelvantFeb 21, 2018Brass Contributor
This script enables the feature in the target site. With PNP powershell cmdlets we can achieve this just in few lines. Please refer to the script using pnp cmdlets below.
# Connect to a site
$cred = Get-Credential
Connect-PnPOnline -Url <Site URL> -Credentials $cred# Enable site pages feature at web
Enable-PnPFeature -Identity B6917CB1-93A0-4B97-A84D-7CF49975D4EC -Scope Web- matt howellApr 30, 2019Brass Contributor
Rajashekhar Sheelvant This is the usual muddled, poorly designed user experience we've come to expect from Msft. No competent company would release 2 incompatible parallel ui's into production environments. None of the questions asked here should have to be asked. Total fail.