Tuesday, June 16, 2009
« Changing ODC links in Excel Services fro... | Main | SPMetal doesn't like spaces »

You know how it is, you start developing a project and then 6 months later you look back and realise you have to document everything you've produced.

I've just gone through that process and need a quick list of all the features ids scattered around various subdirectories of a large project.

sample:

<Feature  Id="886f12cf-97ca-4789-baf8-6f13f9f2cedf"
          Title="PGPSO Contract Management Project Upgrade"
          Description="Feature that upgrades Project Sites for Contract Management."
          Version="12.0.0.0"
          Hidden="FALSE"
          Scope="Web"
          DefaultResourceFile="core"
          ReceiverAssembly="PGPSO_CM_Project_Upgrade, Version=1.0.0.0, Culture=neutral, PublicKeyToken=aa0408b86137366a"
          ReceiverClass="PGPSO_CM_Project_Upgrade.PGPSO_CM_Project_Upgrade"
          xmlns="http://schemas.microsoft.com/sharepoint/">

Firing up Powershell navigating to the root of the solution folders and running this command gets me the list

gci -recurse -filter  feature.xml | % { $contents=get-content $_.fullname; $x=[XML]$contents; "{0} {1}" -f $x.Feature.Id, $x.feature.title }

result:

 

gci is an alias for get-childitem which allow you to recurse subfolders and provide a filter parameter. Then use get-content to open the file, convert to an XML object and then directly reference the Id and title of the feature.xml file.

 

 

Tuesday, June 16, 2009 3:44:34 PM (GMT Standard Time, UTC+00:00)
Very handy tip. Can also be used on 12\TEMPLATE\FEATURES to see what's installed.


One suggestion: Rather than format the values into a string, use Select-Object:
gci -rec . feature.xml | %{ $x = [xml](gc $_.Fullname); $x.Feature } | select Id, Title


Or just skip the select so you can sort, group, inspect receivers, etc. Super handy, that PowerShell. :)

Cheers ~
Keith
Tuesday, June 16, 2009 8:50:47 PM (GMT Standard Time, UTC+00:00)
Great points Keith, thanks.
colin byrne
Comments are closed.