SharePoint 2010 PowerShell enable/disable feature for all site collections

1

Category : Powershell, sharepoint

A lot of enterprise portals build multiple site collections within the web application of a SharePoint farm. This is a scalable architecture that allows for separation of databases, site collection administration differentiation and a host of other benefits from the SharePoint administration point of view. This architecture also has some downsides including global navigation and different settings on the multiple site collections. If this is your architecture of choice, enabling features across all site collections is also an issue. What if you buy a third party product and need to enable the feature globally? What if you build a reusable component? Every time I need to do this I find myself Googling Binging Googling the answer to this question.

Below are helpful commands that wrap the Enable and Disable features in the get all site collections for a web application. Also, notice the “whatif” command for testing. This is a very valuable functionality of PowerShell that I highly suggest using before running the commands.

Enable Feature Testing

Get-SPWebApplication “<WebApplicationURL>” | Get-SPSite -Limit ALL |
ForEach-Object {Enable-SPFeature “MyFeatureID” -Url $_.Url -WhatIf}


Enable Feature without Confirmation

Get-SPWebApplication “<WebApplicationURL>” | Get-SPSite -Limit ALL |
ForEach-Object {Enable-SPFeature “MyFeatureID” -Url $_.Url -confirm:$false}’


Disable Feature Testing

Get-SPWebApplication “<WebApplicationURL>” | Get-SPSite -Limit ALL |
ForEach-Object {Disable-SPFeature “MyFeatureID” -Url $_.Url -WhatIf}


Disable Feature without Confirmation

Get-SPWebApplication “<WebApplicationURL>” | Get-SPSite -Limit ALL |
ForEach-Object {Disable-SPFeature “MyFeatureID” -Url $_.Url -confirm:$false}



Hope this helps someone else. Also, sorry for the forum I originally got this answer from. I’d give you credit if I remembered where it was. I just had this in my notes and decided to put it on my blog in case it helps others.

Comments (1)

I’m trying to find a list of all the functioanlit SharePoint 2010 offers and which functionality can be enabled/disabled at the adiministrator level. Thoughts?