Share via


Getting the feature names available on the server

One script that comes in handy when you have the following type of issue ( rare but it happens ).

Say you have deployed a webpart through a custom solution.

From time to time on your load balanced farm, the page crashes . Investigating , you find out that the solution was not added on one web front end under \Template\Features . You add the solution definition there and all works fine all the time.

Now.. wouldn't it be nice to be able to check quickly the deployed solutions ?

Here's a script for you that attempts to accomplish that.

NOTE : the script comes with NO warranties.run it at your own risk.

$localFeatures = Get-ChildItem "C:\Program Files\common files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\FEATURES" -filter "Feature.xml" -Recurse

$processedFeatures =@()

foreach($featureDef in $localFeatures)

{

    $featureAsXML = [xml](Get-Content $featuredef.PSPath)

    $featureAsPSObject = New-Object -TypeName "PSObject" -Property @{

    Id =$featureAsXML.Feature.Id

    FeatureName = $featuredef.Directory.Name

Title = $featureAsXML.Feature.Title

Description=$featureAsXML.Feature.Description

Scope = $featureAsXML.Feature.Scope

Hidden =$featureAsXML.Feature.Hidden

ReceiverAssembly = $featureAsXML.Feature.ReceiverAssembly

ReceiverClass = $featureAsXML.Feature.ReceiverClass

}

$processedFeatures+=$featureAsPSObject

}

$processedFeatures |Out-GridView

$processedFeatures |Export-CliXml C:\Temp\Features.xml

At the end, if you want to reuse this file you can just do :

$processedFeatures=Import-CliXml C:\Temp\Features.xml