Wednesday, October 6, 2010

Looping through all SharePoint 2010 sites with PowerShell

Just needed to loop through all SPS2010 sites and disable and enable a feature. The following PowerShell script does this. (this outputs the site url so I can observe the progress)


$site = Get-SPSite -identity http://{siteurl}


$site | Get-SPWeb -limit all | ForEach-Object { Write-Host $_.Url; Disable-SPFeature -Identity {featureid} -url $_.Url; Enable-SPFeature -Identity {featureid} -url $_.Url }

No comments: