Home Contact

The Frog Pond of Technology

Ripples of Knowledge for SharePoint and Other .Net Technologies

News

 Subscribe to this blog


About Me

Name:
Brian T. Jackett
Location:
Columbus, OH
Company:
Microsoft

Find me on...

Tag Cloud


Archives

Post Categories

Syndication:

PowerShell Script: Find All SharePoint Features Installed On Farm

     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


Thursday, October 8, 2009 8:20 PM

Feedback

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

Your article is nice.Thanks for your sharing,it helps me more.I will look forward to your more wonderfull articles.Have a good time. 10/8/2009 10:37 PM | True Religion jeans

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

Glad you both liked the post. I'll be posting some more PowerShell scripts I've developed over the next few weeks. 10/8/2009 11:38 PM | Brian Jackett

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

Helped out a bunch - thanks for the script. I saw that there was no -enumfeatures option on stsadm and figured powershell might be the answer. Thankfully I found your script ...

thanks again. 1/26/2010 3:27 PM | neil

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

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. 9/13/2010 3:17 PM | Matt

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

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.
9/13/2010 5:59 PM | Brian T. Jackett

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

Any chance this output would tell me *where* specific features are in use in the farm, down to the site or page level? 1/14/2011 9:03 PM | SJOMVL

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

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.
1/15/2011 9:05 AM | Brian T. Jackett

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

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 1/17/2011 7:46 PM | Will

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

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.
1/18/2011 4:06 PM | Brian T. Jackett

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

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. 1/20/2011 11:23 PM | Will

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

Will,

Because SPWeb.Features is a collection of objects you must iterate through them and match the DefinitionId property of an individual SPFeature against your Guid value. That sub-select would look like this:

$result = $web.Features | where {$_.DefinitionId -eq "<Guid>"}
1/20/2011 11:37 PM | Brian T. Jackett

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

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. 4/25/2012 9:31 AM | Jakob Flygare

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

Jakob,

You could use my template for traversing all sites in a SharePoint 2007 or 2010 farm on this blog post:

http://briantjackett.com/archive/2011/09/19/powershell-script-to-traverse-all-sites-in-sharepoint-2010-or.aspx
4/30/2012 8:50 PM | Brian T. Jackett

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

Jakob,

I finally had a chance to build a proof of concept for gathering which features are activated at each of the levels (farm and all web apps, sites, and webs). I'll be posting to my blog in a week or so when I can clean it up a bit.
6/13/2012 12:26 PM | Brian T. Jackett

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

Hi,

The output is not in a proper format in the text file. Infact the output is not tabular...is there a way out to make the output tabular 7/18/2012 4:37 AM | Ajanta

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

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
7/21/2012 4:21 PM | Brian T. Jackett

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

you can use Get-Farm,

(Get-Farm).FeatureDefinitions 12/26/2012 8:04 AM | Mike Chaliy

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

Mike,

You are correct with that one liner for 2010 and beyond. As I mentioned in a previous comment my above script was targeted to SharePoint 2007 before native commandlets existed (and back in my early days of scripting).
12/26/2012 8:39 AM | Brian T. Jackett

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

Works perfectly for me, thank alot :) 1/18/2013 8:04 AM | Kukutatu

# Custom SharePoint Development

This PowerShell script will find where a SharePoint 2007 feature was activated at any level of the farm. If you specify no parameters it will find all features 1/31/2013 12:53 AM | Chadwick Price

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

This worked great. I had to load the:

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

But once done worked like a charm. Big Thankyou! 3/6/2013 1:02 PM | Bill S

# re: PowerShell Script: Find All SharePoint Features Installed On Farm

Hello,

Thanks for your script :)

could you please let me know that How to get web soultions with hoster name & webapplication url where all wsp solutions are deployed in the farm.

Thanks 10/15/2014 5:28 AM | Adithya

Post A Comment
Title:
Name:
Email:
Comment:
Verification: