1.8 KiB
Montag, 29. Juli 2019
14:06
SharePoint PowerShell to activate publishing feature at site collection:
Here is the PowerShell to activate publishing feature at site collection.
1 | Enable-SPFeature -Identity "PublishingSite" -url "http://intranet.crescent.com" |
---|
Lets add some error handling & variables to it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Variables $SiteURL="http://intranet.crescent.com" $FeatureName = "PublishingSite"
#Check if publishing feature is already activated in the site collection $Feature = Get-SPFeature -site $siteURL | Where-object {$_.DisplayName -eq $FeatureName} if($Feature -eq $null) { #Enable the Publishing feature Enable-SPFeature -Identity $FeatureName -url $SiteURL -Confirm:$False
Write-host "Publishing Feature Activated on $($SiteURL)" -ForegroundColor Green } else { Write-host "Publishing Feature is already Active on $($SiteURL)" -ForegroundColor Red } |
---|
Enable-SPFeature -Identity $featureID -Url $web.Url
BKK ComposedLook ID bd7aac55-c1e3-4aeb-b014-7d5dd3cf6eb6