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.
- Version 1 – simple output of all features in table format sorted by solutionId then featureName
- 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
