3

I'm looking for a Powershell script to enable the SharePoint Server Publishing site feature on all sites in a single site collection or all site collections.

6

To activate the Publishing feature on all the sites in a site collection use the script below. Publishing Infrastructure feature must be enabled for the site collection first.

Get-SPWeb -Site "http://rootWebUrl" -Limit all | % {Enable-SPFeature "PublishingWeb" -url $_.url}

For all site collections in a web application:

foreach ($site in $webApp.Sites)
{
    #first enable the Publishing infrastructure feature
    Enable-SPFeature "PublishingSite" -url $site.url
    Get-SPWeb -Site $site.Url -Limit all | % {Enable-SPFeature "PublishingWeb" -url $_.url}
}
| improve this answer | |
  • this tries to enable the feature at Web level, not site collection level, and fails ,of course, because it's not enabled at site collection level. – malexandrum Nov 25 '14 at 9:36
  • 2
    @alex-m PublishingSite is a site level feature and PublishingWeb is a web level feature. – Naim Murati Nov 25 '14 at 11:39
1

For me, this worked better for all sites in a web application. Although I had some sites that already had publishing enabled and I wasn't sure how to skip those.

$sites = Get-SPSite -WebApplication $yourWebApp -Limit All

foreach ($site in $sites)
{
    #first enable the Publishing infrastructure feature
    Enable-SPFeature "PublishingSite" -url $site.url
    Get-SPWeb -Site $site.Url -Limit all | % {Enable-SPFeature "PublishingWeb" -url $_.url}
} 
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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