I am working with a lot of site collections, which each have many subsites. I have custom branding that will only work if the publishing feature is activated on each site and subsite. I tried this:
$sites = Get-SPSite -WebApplication "https://myWebApp.com/" -Limit All
foreach ($site in $sites)
{
Enable-SPFeature "PublishingSite" -url $site.url
}
That only activated publishing on all the root site collections, not the subsites. So then I tried adding this in the loop:
Get-SPWeb -Site $site.Url -Limit all | % {enable-SPFeature "PublishingSite" -url $_.url}
When I did that I got this error:
The specified feature applies to the entire site collection, but the specified URL refers to a particular sub site. To apply this feature to the entire site collection, use the root URL 'https://myWebApp.com/sites/aSiteCollection'
What do I need to change so that every "SPWeb" can have the publishing feature activated?