Home Contact

The Frog Pond of Technology

Ripples of Knowledge for SharePoint and Other .Net Technologies

News

 Subscribe to this blog


Upcoming speaker at:

About Me

Name:
Brian T. Jackett
Location:
Columbus, OH
Company:
Sogeti USA

Find me on...

Speaker Rate

Twitter












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


Feedback

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

Very informative and interesting! 10/8/2009 10:35 PM | supra shoes

# 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

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