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
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#489654Your article is nice.Thanks for your sharing,it helps me more.I will look forward to your more wonderfull articles.Have a good time.
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#489660Glad you both liked the post. I’ll be posting some more PowerShell scripts I’ve developed over the next few weeks.
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#503279Helped 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.
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#537613Note 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.txtRun 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.
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#537622Matt, 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.
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#557910Any chance this output would tell me *where* specific features are in use in the farm, down to the site or page level?
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#557958SJOMVL, 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.
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#558333Thanks 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
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#558478Will, 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.
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#558869Hi 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 actionto 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.
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#558871Will,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>”}
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#612638Did 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.
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#612943Jakob,You could use my template for traversing all sites in a SharePoint 2007 or 2010 farm on this blog post:https://briantjackett.com/archive/2011/09/19/powershell-script-to-traverse-all-sites-in-sharepoint-2010-or.aspx
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#615061Jakob,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.
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#616684Hi,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
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#616808Ajanta,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).https://briantjackett.com/archive/2012/07/02/powershell-script-to-find-where-sharepoint-2010-features-are-activated.aspx
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#623093you can use Get-Farm, (Get-Farm).FeatureDefinitions
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#623094Mike,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).
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#624026Works perfectly for me, thank alot 🙂
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#624553This 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
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#625776This worked great. I had to load the:[void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)But once done worked like a charm. Big Thankyou!
LikeLike
Originally posted on: https://briantjackett.com/archive/2009/10/08/powershell-script-find-all-sharepoint-features-installed-on-farm.aspx#641286Hello,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
LikeLike
THX! Great post, helped me a lot!
LikeLike