How to: Activate and re-activate installed features using a SharePoint power shell script

I would like to share a simple SharePoint power shell script with you which you can use to activate and re-activate installed features.

This example re-activates the Employee Training Management feature. If you upgrade to a newer version, you should always re-activate the feature and if you have to do this for several SharePoint sites it makes sense to use a script. The script is as follows:

$webs = Get-SPWebApplication | Get-SPSite -Limit All | Get-SPWeb -Limit All 
$featureID = [Guid]"26583aab-d708-4dc1-92f1-36843fafcb40" 
ForEach($w in $webs){ 
if($w.Features[$featureID])     { 
$w.Url 
$w.Features.Remove($featureID); 
$w.Features.Add($featureID);     } 
}
$webs = Get-SPWebApplication | Get-SPSite -Limit All | Get-SPWeb -Limit All 
$featureID = [Guid]"26583aab-d708-4dc1-92f1-36843fafcb40" 
ForEach($w in $webs){ 
if($w.Features[$featureID])     { 
$w.Url 
$w.Features.Remove($featureID); 
$w.Features.Add($featureID);     } 
}

I hope you found this information useful. If you have any problems or any other questions, please send an e-mail to [email protected] or post a comment.