Activate / Deactivate Feature with PowerShell on all site collections of the webapp


When we do some change on the solution  specially on the branding  for exmple ( display teamplate),we should update also existing sites collection and replace old files with new one after the deployment. So this powershell Script with do this on the all farm.
$feature = Get-SPFeature -Identity "ID OF THE FEATURE"
$siteCollections = Get-SPSite –WebApplication $webhubUrl -Limit ALL
$siteCollections | foreach-object {
   Write-Host "Deactivating" $feature.DisplayName "on" $_.Url -foregroundcolor yellow
   Disable-SPFeature $feature -Url $_.Url -confirm:$false

$siteCollections | foreach-object {
   Write-Host "Activating" $feature.DisplayName "on" $_.Url -foregroundcolor green
   Enable-SPFeature $feature -Url $_.Url

You Might Also Like

0 commentaires