Locating SharePoint Features with PowerShell

I figure I’d write this quick post moreso for remembering sake than anything else….

We are in the middle of creating deployment scripts for our SharePoint Development cycle. Today we have the task of enabling various different features using PowerShell. A good site to view various different powershell syntax can be found here:


One of the tasks we needed to do was to enable some of the standard SharePoint features, such as the SharePoint Enterprise Features explained here.

Well naturally we decided to place these features inside a web site template, and then upon deployment run a powershell script to apply the web template to the site as found in this code below:

   1: Param($SiteUrl,[String]$WebTemplateName,$ScriptsFolder)


   3: #### Properties ####

   4: $getValue = $EnvConfig


   6: $watch = New-Object System.Diagnostics.StopWatch

   7: #### End Properties ####


   9: echo "Checking Execution Policy"

  10: &;$ScriptsFolder\WriteLog.ps1 -Message "Checking Execution policy"


  12: $execPolicy = Get-ExecutionPolicy

  13: if(!(($execPolicy) -eq "RemoteSigned")){

  14:     Set-ExecutionPolicy RemoteSigned

  15:     echo "Setting Execution Policy to RemoteSigned"

  16:     &;$ScriptsFolder\WriteLog.ps1 -Message "Setting Execution policy to RemoteSigned"


  18: }



  21: function apply-web-template(){

  22:     [System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c") 

  23:     echo "Applying web template to site collection"

  24:     &;$ScriptsFolder\WriteLog.ps1 -Message "Applying web template to site collection"



  27:     $site= new-Object Microsoft.SharePoint.SPSite($SiteUrl)

  28:     $site.RootWeb.ApplyWebTemplate($WebTemplateName)

  29:     $site.Dispose()

  30: }


  32: #Not continue on error

  33: trap [Exception] {

  34:     echo "There was errors"

  35:     break;

  36: }


  38: $watch.Start()


  40: apply-web-template

  41: $watch.Stop()

  42: $time = $watch.Elapsed.ToString()

  43: echo "Time elapsed: $time"

  44: &;$ScriptsFolder\WriteLog.ps1 -Message "Time elapsed: $time"


  46: echo "Setting Execution policy back to $execPolicy"

  47: &;$ScriptsFolder\WriteLog.ps1 -Message "Setting Execution policy back to $execPolicy"

  48: Set-ExecutionPolicy $execPolicy


However upon running the script we ran into some errors. These errors were dealing with individual features not being enabled for various reasons. We wanted to test individual features being enabled using PowerShell. Question is, how do you determine some of the SharePoint Features Out of the box, because they are not named according to anything that make sense…

Take a look:


What’s the name of the above feature? It’s not: SharePoint Server Enterprise Site Collection  It’s actually named PremiumSite.

So How do you figure out some of the others?

Well this is what I did. I knew from google that one of the features I was interested in was the SharePoint Enterprise Features thus I started there. From google I learned that this feature can be found in the Folder: C:\program files\common files\microsoft shared\web server extensions\14\template\features\PremiumSite.

When I went to this location I found this file:



Notice above the value for Title and Description. These values use the embedded resource mechanism of the .Net Framework, and the Resources token to get exactly what these names mean. Thus I went searching, the file, osrvcore either had to be an assembly or a resource file that could dynamically be converted into an assembly at runtime, so I searched my computer.

What I found was a file in this directory:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Resources


The file name osrvcore.en-US.resx  was just the file I was looking for. I opened this file up and saw all the names of the Out of the box SharePoint Features, and where they point to feature folder wise.


In this resource file, the name of the feature found in the c:\program files\common files\microsoft shared\web server extensions\14\template\features will be PremiumSite minus the suffix “FeatureTitle”.

Now we can write a powershell script such as this to get this and related features, and also enable them such as this:

   1: Get-SPFeature 

   2:     | where-object {$_.displayname -eq "PremiumSite" } 

   3:     | %{ Enable-SPFeature -Identity $_ -url "http://localhost" }




One thought on “Locating SharePoint Features with PowerShell

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s