Sunday, April 8, 2012

Powershell to find site collections with specific feature activated

This is a one liner Powershell to find site collections which have the specific feature activated. See the below example, it display URLs of site collections where "SharePoint Publishing Infrastructure" feature is activated. The "PublishingSite" is the name of publishing infrastructure feature.

Get-SPSite -Limit All| Where-Object {(Get-SPFeature "PublishingSite" -ErrorAction SilentlyContinue -Site $_.Url) -ne $null } | Select Url

So the format is

Get-SPSite -Limit All | Where-Object { (Get-SPFeature <Feature Name> -ErrorAction SilentlyContinue -Site $_.Url) -ne $null } | Select Url

Note that it will only check for site collection scoped features. The above Powershell can be modified for web scoped features as below.

Get-SPSite -Limit All| Get-SPWeb -Limit All | Where-Object { (Get-SPFeature <Feature Name> -ErrorAction SilentlyContinue -Web $_.Url) -ne $null } | Select Url

e.g. To check Publishing feature activation status at web scope, it will look like as below. "PublishingWeb" is a web scoped feature.

Get-SPSite -Limit All| Get-SPWeb -Limit All | Where-Object { (Get-SPFeature "PublishingWeb" -ErrorAction SilentlyContinue -Web $_.Url) -ne $null } | Select Url

This powershell block can be extended for web application/Farm scoped features also.
Post a Comment