Created
October 25, 2013 13:48
-
-
Save RyanHirsch/7154977 to your computer and use it in GitHub Desktop.
Toggle SharePoint feature on site and all children
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function TraverseWebs($url, $feature) | |
{ | |
$web = Get-SPWeb $url | |
foreach($child in $web.Webs) | |
{ | |
ToggleFeature $web $feature | |
if($child.Webs) | |
{ | |
TraverseWebs($child.Url) | |
} | |
} | |
} | |
Function ToggleFeature($web, $featureName) | |
{ | |
$results = Get-SPFeature -Web $web | Where-Object { $_.DisplayName -eq $featureName } | |
if($results) { | |
Disable-SPFeature -Identity $featureName -Url $web.Url -Confirm:$false | |
Enable-SPFeature -Identity $featureName -Url $web.Url | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment