Friday, 10 February 2017

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

Hello,


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

Featured Post

Developer Dashbord SharePoint PowerShell

Developer Dashbord $cs = [Microsoft.SharePoint.Administration.SPWebService]::ContentService $dash= $cs.DeveloperDashboardSettings $dash....