How to reactivate feature on all webs in a site collection

Sometimes you need to reactivate a same web feature many times, whereever it is activated.

Here is a handy Powershell script

Add-PSSnapin Microsoft.SharePoint.PowerShell
$site = get-spsite http://mysharepoint.com
foreach($web in $site.AllWebs)
{
#Get the feature based on feature Id
$results = @()  Get-SPFeature -Web $web -Limit All | % {
$feature = $_;
if ($_.ID -eq “<GUID here>”)
{
Write-host “Feature Activated at” $web.Url
Enable-SPFeature -Identity $feature -URL $web.Url -Force
Write-Host $_.ID “is Re-activated at :” $web.Url
}
}
}

Leave a Reply