Sharepoint 2010: Deactivate and Activate Feature with Power Shell
Sometimes, you can have trouble with feature upgrade in your site.
Especially if you upgrade event receiver, adding new trigger.
If you have many sub site using this feature, you can use Power Shell to deactivate and activate feature.
This mine:
Especially if you upgrade event receiver, adding new trigger.
If you have many sub site using this feature, you can use Power Shell to deactivate and activate feature.
This mine:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$rootUrl = "http://[SERVERNAME]"
$site = Get-SPSite $rootUrl
foreach($web in $site.AllWebs)
{
$url = $web.Url
if($url -ne $rootUrl){
foreach($feature in Get-SPFeature -Web $url)
{
$featureName = $feature.DisplayName
if($featureName -eq "FEATURE NAME")
{
"Disable and Enable feature $featureName in $web"
Disable-SPFeature -Identity FEATURENAME -Url $url -Confirm:$false
Enable-SPFeature -Identity FEATURENAME -Url $url
break;
}
}
}
}
$rootUrl = "http://[SERVERNAME]"
$site = Get-SPSite $rootUrl
foreach($web in $site.AllWebs)
{
$url = $web.Url
if($url -ne $rootUrl){
foreach($feature in Get-SPFeature -Web $url)
{
$featureName = $feature.DisplayName
if($featureName -eq "FEATURE NAME")
{
"Disable and Enable feature $featureName in $web"
Disable-SPFeature -Identity FEATURENAME -Url $url -Confirm:$false
Enable-SPFeature -Identity FEATURENAME -Url $url
break;
}
}
}
}
Comments
Post a Comment