DisableFeatures
$webApp = "http://WebAppUrl/"
$StapleFeature = Get-SPFeature | where {$_.DisplayName -eq "Name"}
$BrandingFeature = Get-SPFeature | where {$_.DisplayName -eq "Name"}
$WebPartsFeature = Get-SPFeature | where {$_.DisplayName -eq "Name"}
# Site collection scoped features
# Get all sites in the web app and if the feature exists, disable it
Get-SPSite -WebApp $webApp | foreach {
if($_.Features[$StapleFeature.ID]) {
Disable-SPFeature $StapleFeature -url $_.URL -Force -Confirm:$false
Disable-SPFeature $WebPartsFeature -url $_.URL -Force -Confirm:$false
}
}
# Web scoped features
# Get all webs in all sites in the web app and if the feature exists, disable it
Get-SPSite -WebApp $webApp | Get-SPWeb -limit all | foreach {
if($_.Features[$BrandingFeature.ID]) {
Disable-SPFeature $BrandingFeature -url $_.URL -Force -Confirm:$false
}
}
Enable Features
$webApp = "http://WebAppUrl/"
$StapleFeature = Get-SPFeature | where {$_.DisplayName -eq "Name"}
$BrandingFeature = Get-SPFeature | where {$_.DisplayName -eq "Name"}
$WebPartsFeature = Get-SPFeature | where {$_.DisplayName -eq "Name"}
# Site collection scoped features
# Enable features in all sites in the web app
Get-SPSite -WebApp $webApp | foreach {
Enable-SPFeature $StapleFeature -url $_.Url -Force
Enable-SPFeature $BrandingFeature -url $_.Url -Force
Enable-SPFeature $WebPartsFeature -url $_.Url -Force
}
I only had a couple of web apps, so just replaced the web app URL $webApp for each one and ran the scripts. You could just put another foreach and loop through all the webs if needed.