Archive for March, 2014

Generate feature documentation

March 31, 2014 2 comments

For my projects I always provide documentation about the solutions our team has developed. Part of the development is an overview of the features which are added to the different solutions. This because most of the features tend to be hidden and the customer and administrators will not use Visual Studio to check which features are added.

As most developers I don’t like to document everything twice and on multiple locations. All features in my project are already documented in Visual Studio. I’ve added titles, images, descriptions etc. This information can easily be reused to generate documentation about the features. For that, I use the following PowerShell script:


# Set the feature folder based on the SharePoint version
$featureFolder = “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\FEATURES”

# Provide a prefix to filter the set of features
$featureFolderPrefix = “Macaw.”

# Initialise a counter
$counter = 0

# Loop through all features
foreach($folder in Get-ChildItem -LiteralPath $featureFolder | where { $_.PSIsContainer -and $_.Name.StartsWith($featureFolderPrefix,“CurrentCultureIgnoreCase”) }) {

   #Increment the counter

   # Retrieve the feature XML
   $featureXML = Get-ChildItem $folder.FullName -Filter feature.xml -Recurse
   [xml] $featureContent = Get-Content $featureXML.FullName
   $feature = $featureContent.Feature

   # Write some of the properties to screen
   $feature | select Title, Description, Id, Scope,
     @{Label=“Hidden”;Expression={if($featureContent.Feature.Hidden) { “Yes”} else { “No”}}},
     @{Label=“Full name”;Expression={$featureXML.FullName}},

   # Split the results with an empty row
   Write-Host “”

Ben Prins

What I want to remember about SharePoint

my world of work and user experiences

Bram de Jager - Coder, Speaker, Author

Office 365, SharePoint and Azure