The script on this post will find where features are activated within your SharePoint 2010 farm.
Problem
Over the past few months I’ve gotten literally dozens of emails, blog comments, or personal requests from people asking “how do I find where a SharePoint feature has been activated?” I wrote a script to find which features are installed on your farm almost 3 years ago. There is also the Get-SPFeature PowerShell commandlet in SharePoint 2010. The problem is that these only tell you if a feature is installed not where they have been activated. This is especially important to know if you have multiple web applications, site collections, and /or sites.
Solution
The default call (no parameters) for Get-SPFeature will return all features in the farm. Many of the parameter sets accept filters for specific scopes such as web application, site collection, and site. If those are supplied then only the enabled / activated features are returned for that filtered scope. Taking the concept of recursively traversing a SharePoint farm and merging that with calls to Get-SPFeature at all levels of the farm you can find out what features are activated at that level. Store the results into a variable and you end up with all features that are activated at every level.
Below is the script I came up with (slight edits for posting on blog). With no parameters the function lists all features activated at all scopes. If you provide an Identity parameter you will find where a specific feature is activated. Note that the display name for a feature you see in the SharePoint UI rarely matches the “internal” display name. I would recommend using the feature id instead. You can download a full copy of the script by clicking on the link below.
Note: This script is not optimized for medium to large farms. In my testing it took 1-3 minutes to recurse through my demo environment. This script is provided as-is with no warranty. Run this in a smaller dev / test environment first.
function Get-SPFeatureActivated
{
# see full script for help info, removed for formatting
[CmdletBinding()]
param(
[Parameter(position = 1, valueFromPipeline=$true)]
[Microsoft.SharePoint.PowerShell.SPFeatureDefinitionPipeBind]
$Identity
)#end param
Begin
{
# declare empty array to hold results. Will add custom member `
# for Url to show where activated at on objects returned from Get-SPFeature.
$results = @()
$params = @{}
}
Process
{
if([string]::IsNullOrEmpty($Identity) -eq $false)
{
$params = @{Identity = $Identity
ErrorAction = “SilentlyContinue”
}
}
# check farm features
$results += (Get-SPFeature -Farm -Limit All @params |
% {Add-Member -InputObject $_ -MemberType noteproperty `
-Name Url -Value ([string]::Empty) -PassThru} |
Select-Object -Property Scope, DisplayName, Id, Url)
# check web application features
foreach($webApp in (Get-SPWebApplication))
{
$results += (Get-SPFeature -WebApplication $webApp -Limit All @params |
% {Add-Member -InputObject $_ -MemberType noteproperty `
-Name Url -Value $webApp.Url -PassThru} |
Select-Object -Property Scope, DisplayName, Id, Url)
# check site collection features in current web app
foreach($site in ($webApp.Sites))
{
$results += (Get-SPFeature -Site $site -Limit All @params |
% {Add-Member -InputObject $_ -MemberType noteproperty `
-Name Url -Value $site.Url -PassThru} |
Select-Object -Property Scope, DisplayName, Id, Url)
$site.Dispose()
# check site features in current site collection
foreach($web in ($site.AllWebs))
{
$results += (Get-SPFeature -Web $web -Limit All @params |
% {Add-Member -InputObject $_ -MemberType noteproperty `
-Name Url -Value $web.Url -PassThru} |
Select-Object -Property Scope, DisplayName, Id, Url)
$web.Dispose()
}
}
}
}
End
{
$results
}
} #end Get-SPFeatureActivated
Snippet of output from Get-SPFeatureActivated
Conclusion
This script has been requested for a long time and I’m glad to finally getting a working “clean” version. If you find any bugs or issues with the script please let me know. I’ll be posting this to the TechNet Script Center after some internal review. Enjoy the script and I hope it helps with your admin / developer needs.
-Frog Out

