You have a modern site in SharePoint Online, but you want to get a classic page with a script editor webpart. The problem is all of this is missing! Use the PowerShell script below to enable the features required to support this.
Remember that Communication sites do not support this, only Team sites!
Import-Module PnP.Powershell
$SiteURL = "https://contoso.sharepoint.com/sites/MYMODERNSITE"
Connect-PnPOnline $SiteURL -Interactive
$Template = Get-SPOSite -Identity $SiteURL -detailed | Select -ExpandProperty template
if($Template -eq "SITEPAGEPUBLISHING#0"){Write-Host "SharePoint Communication Sites
(publishing) do not allow script editor webparts. Recreate the site as a Team
site"}
else{
Write-Host "Enabling site features to support script editor
webparts"
SharePoint Server Publishing Infrastructure of Site Collection
Enable-PnPFeature -Identity f6924d36-2fa8-4f0b-b16d-06b7250180fa -force -Scope site
#SharePoint Server Publishing of Site
Enable-PnPFeature -Identity 94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb -force -Scope web
Set-SPOsite $SiteURL -DenyAddAndCustomizePages 0
Set-PnPSite -Identity $SiteURL -NoScriptSite $false
Set-PnPTenantSite -Identity $SiteURL -DenyAddAndCustomizePages:$false
}
Sources:
- Team Site vs. Communication Site - Which one should I choose? | Microsoft Learn
- How to enable script editor web part in SharePoint Online Office 365 - SPGuides
- Erro while trying to activate SharePoint server publishing infrastrure feature - Microsoft Q&A
- Content Editor, Script Editor Web Part Missing in SharePoint Online? - SharePoint Diary
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.