Activate SharePoint Server Publishing Infrastructure on Modern

By default, when you trying to activate the SharePoint Server Publishing Infrastructure feature, you’re getting an error message on your SharePoint. That is because there are some hidden SharePoint features required to be able to activate SharePoint Server Publishing Infrastructure. This option is disabled with the SharePoint Modern Experience.

DISCLAMER: Enabling Publishing features in Modern SharePoint site will make then unsupported.

On the Reference section below is more information about the features that needed to be activated to activate successfully this feature. Some of these features are not available to be activated on the SharePoint Site Collection and because of that, we need to use PowerShell to activate those. Note this process will change your SharePoint site Structure.

The first step is to allow Custom Script on SharePoint Tenant:

  1. Go to your SharePoint Admin center change the URL to your tenant admin. https://contoso-admin.sharepoint.com
  2. If this opens the new SharePoint admin center, select Classic SharePoint admin center in the left pane.
  3. Select Settings.
  4. Under Custom Script choose:
    • Allow users to run custom script on personal sites.
    • Allow users to run custom script on self-service created sites.
  5. Select OK.

 Note: It can take up to 24 hours for the change to take effect.

The next step is to allow Custom Script on SharePoint Site Collection and for that, we need to use the next PowerShell:

Connect-SPOService -Url https://contoso-admin.sharepoint.com 
Set-SPOSite -Identity https://contoso.sharepoint.com/sites/Publishing -DenyAddAndCustomizePages 0

Finally, we need to connect to the SharePoint Site Collection to activate the features that are required to have the SharePoint Server Publishing Infrastructure activated.

Connect-PnPOnline -url https://contoso.sharepoint.com/sites/Publishing 

Enable-PnPFeature -Identity dffaae84-60ee-413a-9600-1cf431cf0560 -force #RollupPages 
Enable-PnPFeature -Identity 22a9ef51-737b-4ff2-9346-694633fe4416 -force #Publishing
Enable-PnPFeature -Identity f6924d36-2fa8-4f0b-b16d-06b7250180fa -force -Scope site #SharePoint Server Publishing Infrastructure of Site Collection
Enable-PnPFeature -Identity 94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb -force -Scope web #SharePoint Server Publishing Infrastructure of Site 

Conclusion

When all these processes are concluded, you’ll have the SharePoint Server Publishing Infrastructure activated on your Modern Site and start to take the advantages of these older functionalities On the article in the references section, you can find more information about those functionalities.

If you intend to revert back this process, you need to Deactivate the features in the following order:

Connect-PnPOnline -url https://contoso.sharepoint.com/sites/Publishing 

Disable-PnPFeature -Identity 94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb -force -Scope web #SharePoint Server Publishing Infrastructure of Site
Disable-PnPFeature -Identity f6924d36-2fa8-4f0b-b16d-06b7250180fa -force -Scope site #SharePoint Server Publishing Infrastructure of Site Collection

References

22 Comments

  1. Ben said:

    Hi David,
    Great read, do you know how to enable for Communications sites for SharePoint 2019 on prem?

    Thank you.

    September 16, 2019
    Reply
    • David Ramalho said:

      Hi Ben,

      The features that required to be activated are the same, but the way to activate the custom scripts are a bit different. Please review this article and follow the instruction – https://support.bindtuning.com/hc/en-us/articles/360030872511

      Let me know if that worked and thanks for the comment.

      My best,
      David Ramalho

      September 17, 2019
      Reply
  2. Ben said:

    Hi David,
    Thanks a lot for this! Got the features enabled and blanked out…previously working only in SPOL for a long time, going back to onprem I’m having to grease the gears a little.

    Looks like Communication Site Collections do not respond to MMS navigation the way regular publishing sites used to do. If we use these for our main intranet landing page, I’m guessing I’ll have to find a way to use CSS/Java to add global navigation that can connect either to the term store or manage global nave= strictly through CSS.

    Thanks a lot for the reply and placing me on the right path with this,
    Ben

    September 23, 2019
    Reply
    • David Ramalho said:

      Hi Ben,

      Correct, the navigation will be position above the title which not looking great. I would suggest you try a BindTuning for SharePoint 2019. You’ll have the flexibility to use the MMS nav. You’ve trials for testing purposes.

      Thanks and have a great day!
      David Ramalho

      September 23, 2019
      Reply
  3. Jeanette said:

    PowerShell is telling me The Term ‘Connect-SPOService’ is not recognized as the name of a cmdlet, function, script file or operable program. Do I need a particular version of PowerShell?

    November 18, 2019
    Reply
  4. Jose said:

    Plis help

    when i run Connect-PnPOnline -url https://xxxxxxxx

    Import-Module : The specified module ‘SharePointPnPPowerShellOnline’ was not loaded because no valid module file was
    found in any module directory.
    At line:1 char:1
    + Import-Module SharePointPnPPowerShellOnline
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ResourceUnavailable: (SharePointPnPPowerShellOnline:String) [Import-Module], FileNotFou
    ndException
    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

    November 21, 2019
    Reply
  5. Ole E said:

    I successfully connect to the pnp shell.
    But I cant get rid of this write error running enable-pnpfeature.
    Any suggestions?

    PS C:\WINDOWS\System32> Enable-PnPFeature -Identity 22a9ef51-737b-4ff2-9346-694633fe4416 -force
    Enable-PnPFeature : Den eksterne serveren returnerte feilen (403) Forbudt.
    At line:1 char:1
    + Enable-PnPFeature -Identity 22a9ef51-737b-4ff2-9346-694633fe4416 -for …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : WriteError: (:) [Enable-PnPFeature], WebException
    + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Features.EnableFeature

    April 22, 2020
    Reply
    • Ole E said:

      Solved it myself.
      Connecting with -useweblogin fixed it. Used currentuser earlier.
      Using mutifactor authentication on the user. Might have a connection to the solution?
      Just wanted to let you all know.

      April 22, 2020
      Reply
      • David Ramalho said:

        Hi Ole,

        Thank you for your feedback. If you have multifactor authentication on the tenant you need to add that parameter.
        My best,
        David Ramalho

        April 22, 2020
        Reply
  6. Parth Bhuta said:

    Hello David,

    this is my Site “https://abcde.sharepoint.com/” and it’s in the communication site. and I used your steps to activate the publishing features. to work in classic view design. but I’m not able to find the “pages library” folder in it. i can able to find site pages. but the pages are from a modern view. which is useless for me as I want to create a design in a classic view

    can you please help me to solve this.
    Thanks in advance.

    April 30, 2020
    Reply
    • David Ramalho said:

      Hi Parth,

      When these features are activated successfully, the Pages library is created. Run once more the PowerShell to make sure the features are activated.

      My best,
      David Ramalho

      May 4, 2020
      Reply
  7. Sravi said:

    Hi David,

    I tried these steps in the same order to activate the SharePoint publishing infrasture feature on the communication site but they are still not activated. I didn’t see any errors in PowerShell too. How long does it take usually? Really appreciate if you could let me know if there is any way I can figure out what went wrong?

    June 9, 2020
    Reply
    • David Ramalho said:

      Hi Sravi,

      Usually activating these features takes a couple of minutes because this activates some additional features behind the scenes.

      My best,
      David Ramalho

      June 15, 2020
      Reply
    • David Ramalho said:

      Hi Kay,

      From the information that the PnP PowerShell is giving, seems that you don’t have a SharePoint site collection with that name.

      My best,
      David Ramalho

      June 25, 2020
      Reply
      • Stuart said:

        Hello,

        I have a similar issue, I am working on the ‘Top level’ on SharePoint so I presume my line will be;

        Set-SPOSite -Identity https://xxxxxxxxx.xxxxxxxxx.sharepoint.com -Deny…….

        Do I remove the sites/Publishing from the address OR is required?

        January 18, 2021
        Reply
        • David Ramalho said:

          Hi,

          That will be change required on the code. If that site is a SharePoint Modern site, be aware of the potential issue that you may have.

          My best,
          David Ramalho

          January 22, 2021
          Reply
  8. Jaime said:

    Hi David,

    Much appreciate this blog, I am trying to activate SharePoint publishing infrastructure, as it is online it won’t let me, but by Sharepoint Online Management Shell, it should work. I try using the code:

    $siteUrl = “https://MyURL.sharepoint.com/sites/MySite”
    $siteCollection = Get-SPOSite $siteUrl
    Enable-SPFeature “PublishingSite” -Url $siteCollection.Url -force
    Enable-SPFeature “PublishingWeb” -Url $siteCollection.Url -force

    But Enable-SPFeature says it is not a command for cmdlet, I check at the list and in fact, it is not there. Do you know another way to activate it?

    April 8, 2021
    Reply
  9. Tejash Wadkar said:

    Hello
    I am trying same thing for communication site. But I am getting some errors while executing last step and error is “Identity Client Runtime Library (IDCRL) did not get a response from the Login server.”

    December 7, 2023
    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *