PowerShell Script: Find All SharePoint Features Installed On Farm

Reading Time: 2 minutes

     Determining all of the SharePoint features installed on a farm CAN be a very labor intensive process, but it doesn’t have to be.  If you’ve ever used the STSADM command line tool you may be aware that there is an “stsadm –o enumsolutions” command to determine all solutions on the farm, but there is no “stsadm –o enumfeatures” command.  At a client of mine I was doing wrap up documentation and detailing all of our custom WSP solutions (over 20 now) and the associated features (over 70 it turns out.)  Rather than dig through SharePoint admin screens or the numerous Visual Studio projects for hours documenting this information, I decided to fire up my trusty friend PowerShell and see if I couldn’t write a quick script to find the information I was looking for.

     Sure enough, using PowerShell and the SharePoint API I was able to write a script in 5 minutes that saved me over an hour of work.  I created 2 version of the script for different possible needs.

  1. Version 1 – simple output of all features in table format sorted by solutionId then featureName
  2. Version 2 – output of all features in table grouped by solutionId, then solutionId is replaced by actual solution name with a separate lookup (very minor performance loss due solution name replacement)

    Additionally, all out of the box features (solutionId is all 0’s) are ignored so only custom features are returned.  Run the below commands making sure to fill in the appropriate URL for your farm.  Additionally you can download both from my SkyDrive here: Version 1 and Version 2

Version 1
$url = "Your site URL here"

 

$site= new-Object Microsoft.SharePoint.SPSite($url)

 

$site.WebApplication.Farm.FeatureDefinitions `

| where-object {$_.solutionid -ne '00000000-0000-0000-0000-000000000000'} `

| Sort-Object solutionid,displayname `

| ft -property solutionid,displayname,scope -auto > features.txt

 

$site.Dispose()

 

Version 2
$url = "Your site URL here"

 

$site= new-Object Microsoft.SharePoint.SPSite($url)

 

#send all features to output file features.txt

$site.WebApplication.Farm.FeatureDefinitions `

| where-object {$_.solutionid -ne '00000000-0000-0000-0000-000000000000'} `

| Sort-Object solutionid,displayname `

| ft -property displayname,scope -auto -groupBy solutionid > features.txt

 

#replace solutionId in features.txt with solution name

foreach($s in $site.WebApplication.Farm.Solutions)

{

    (Get-Content features.txt) `

    | Foreach-Object {$_ -replace $s.solutionid.ToString(), $s.Name} `

    | Set-Content features.txt    

}

 

$site.Dispose()

 

    Feel free to leave feedback if you find these useful.  I’m starting to build up some more PowerShell + SharePoint scripts for some talks later this fall and it’s always good to know what others are looking to get out of PowerShell scripting.  Thanks for reading.

 

      -Frog Out

22 thoughts on “PowerShell Script: Find All SharePoint Features Installed On Farm

  1. Originally posted on: http://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#537613

    Note that there is also Get-SPFeature, which returns the same list as Farm.FeatureDefinitions. So, you can remove your @site assignments and Dispose(), and just run:

    Get-SPFeature -Limit ALL `
    | Sort-Object scope,displayname,solutionid `
    | ft -property solutionid,displayname,description,scope,id -auto > features.txt

    Run get-help Get-SPFeatureto see the different ways that you can scope the Get-SPFeature. I added the feature ID into the results, so that you can pull that if you need to activate that feature on a specific site.

  2. Originally posted on: http://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#537622

    Matt,

    Thanks for the comment of using the PowerShell commands Get-SPFeature. When I wrote this post it was targeted towards SharePoint 2007 (as 2010 wasn’t out yet). Sorry for not explicitly stating that in the post. Now that SharePoint 2010 is out, yes it’s possible to get the same information in other ways.

  3. Originally posted on: http://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#557958

    SJOMVL,

    The scripts above won’t tell you where a feature is activated. A feature can be targeted to the farm, a web application, a site collection, or a site. As such you would need to write a script to recursively travel through every site and enumerate the features deployed there. Send me an email at brian.jackett@gmail.com and we can discuss more.

  4. Originally posted on: http://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#558333

    Thanks for posting, however, is it possible that the script could list only active features?

    I’m trying to look for a property to filter the features on but can’t seem to find one.

    Also, for SJOMVL see this post on listing all sites and sub sites http://sharepointnomad.wordpress.com/2009/05/08/enumerate-sharepoint-sites-and-subsites-using-powershell/
    I’m sure you could integrate the 2 scripts to list all featues.

    Will

  5. Originally posted on: http://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#558478

    Will,

    The above script identifies the features that are installed on the farm, but not where and if they are activated. To determine which features are activated you would need to get a reference to the specific scope where a feature is implemented (SPFarm, SPWebApplication, SPSite, SPWeb). Once you have that reference the Features property will be a collection of SPFeature objects that are activated on that scope. I hope that makes sense.

    Thanks for the link provided to SJOMVL also.

  6. Originally posted on: http://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#558869

    Hi Brian,

    Thanks for the response however i’m still stuck.

    I was planning on using your script to suck out all the feature guids and then uses these guids in a for each action
    to match all the features to a site.

    When I run the below script it returns no results, is there something special I need to do to extract items in an array?
    I think that is why it’s breaking.

    [void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)

    $url = “http://portal”

    $site = new-Object Microsoft.SharePoint.SPSite($url)

    $site.allwebs | where {$_.Features -eq “0561d315-d5db-4736-929e-26da142812c5”}

    Cheers,

    Will.

  7. Originally posted on: http://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#612638

    Did anyone do this script to show where features are activated (or inactive)?

    Cf.:
    Any chance this output would tell me *where* specific features are in use in the farm, down to the site or page level?

    The scripts above won’t tell you where a feature is activated. A feature can be targeted to the farm, a web application, a site collection, or a site. As such you would need to write a script to recursively travel through every site and enumerate the features deployed there. Send me an email at brian.jackett@gmail.com and we can discuss more.

  8. Originally posted on: http://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#616808

    Ajanta,

    You are correct the output is to a text file, not objects or tabular as I later learned is the proper approach. I recently wrote a new post at the link below to output all features and where they are activated in your SharePoint 2010 farm. If that doesn’t suit your needs you are welcome to modify the output of the scripts on this post (feel free to share back if you do).

    http://briantjackett.com/archive/2012/07/02/powershell-script-to-find-where-sharepoint-2010-features-are-activated.aspx

Leave a Reply

Your email address will not be published. Required fields are marked *

seventeen − 2 =