I am currently working with a large number of site collections, and also a fair few custom solutions.
I have found time and again I need to either activate or even deactivate certain features on multiple site collections.
So the below script will allow you to do this in no time at all.
Hope this helps some others.
First step create a text file in the below format, you only need to define the URL for each Site collection or site.
SiteURL
http://sharepoint/sites/site1
http://sharepoint/sites/site2
http://sharepoint/sites/site3
http://sharepoint/sites/site4
You can list all features installed on your sites by using the following PowerShell: Get-SPFeature | Sort -Property Scope,DisplayName | FT -GroupBy Scope DisplayName,Id
Then use the below PowerShell:
(You will need to update the feature IDs and the write host entries to match the features you wish to activate or deactivate.
$SiteList = Import-Csv Sites.txt
ForEach ($item in $SiteList)
{
If ($item -ne $null)
{
Write-Host "Activated Branding Feature for: $($item.SiteURL)" -foregroundcolor cyan;
Enable-SPFeature -id ed8d4f9d-c5a3-4358-a2ef-68be0163677f -URL
"$($item.SiteURL)"
Enable-SPFeature -id 36684dc7-fc72-4ec8-b056-111ead3f453a -URL "$($item.SiteURL)"
Write-Host "Activated Branding Features for: $($item.SiteURL)"
-foregroundcolor green;
Disable-SPFeature -id
cf724a88-9c1c-4f55-957a-d3f5be79a51e -URL "$($item.SiteURL)"
Write-Host "Deactivated Workflow Feature for: $($item.SiteURL)" -foregroundcolor green;
}
}
$web.update()
$web.Dispose()
Thank you Matt!
ReplyDelete