enable or disable a feature for all subsites
I have run into situations where I had to rapidly change features or other aspects of subsites across multiple site collections. How can you do that with PowerShell? It turns out to be quite easy. You don't even need a script. You can run a nested command. Here is the example on how to enable a feature on every site and subsite in the farm:
get-spsite|get-spweb | foreach-object {enable-spfeature -id hold -url $_.Url}
Similarly, you can disable any feature across all subsites and sites with this command:
get-spsite|get-spweb | foreach-object {disable-spfeature -id hold -url $_.Url -confirm:$false}
Using this logic, you can also change other elements on sites without writing a script.
get-spsite|get-spweb | foreach-object {enable-spfeature -id hold -url $_.Url}
Similarly, you can disable any feature across all subsites and sites with this command:
get-spsite|get-spweb | foreach-object {disable-spfeature -id hold -url $_.Url -confirm:$false}
Using this logic, you can also change other elements on sites without writing a script.
Comments
$webAppsFeatureId = $(Get-SPFeature -limit all | where {$_.displayname -eq "OfficeWebApps"}).Id
Get-SPSite -limit ALL |foreach{Enable-SPFeature $webAppsFeatureId -url $_.URL }