Monday, September 10, 2012

How to Determine Installed Sharepoint 2010 SKU

I had an issue arise where I had to determine whether a SharePoint 2010 server was installed with SharePoint 2010 Foundation or one of the SharePoint Server products (Standard/Enterprise). After a lot of searching, I found an MSDN article that shows how to perform the task in .Net, but this seemed fairly useless because I didn't want to have to compile an application in C# just to determine the version. Below is a PowerShell port of the application demonstrated on MSDN:

# SharePoint 2010 SKU List Script
# Developed/Copyright September 2012 by Mike Burr
# Provided AS-IS With No warranty
# Based loosely on http://msdn.microsoft.com/en-us/library/ff721969.aspx
#

$featureindex = @{}
$featureindex["BEED1F75-C398-4447-AEF1-E66E1F0DF91E"] = "SharePoint Foundation 2010"
$featureindex["1328E89E-7EC8-4F7E-809E-7E945796E511"] = "Search Server Express 2010"

$featureindex["B2C0B444-3914-4ACB-A0B8-7CF50A8F7AA0"] = "SharePoint Server 2010 Standard Trial"
$featureindex["3FDFBCC8-B3E4-4482-91FA-122C6432805C"] = "SharePoint Server 2010 Standard"
$featureindex["88BED06D-8C6B-4E62-AB01-546D6005FE97"] = "SharePoint Server 2010 Enterprise Trial"
$featureindex["D5595F62-449B-4061-B0B2-0CBAD410BB51"] = "SharePoint Server 2010 Enterprise"

$featureindex["BC4C1C97-9013-4033-A0DD-9DC9E6D6C887"] = "Search Server 2010 Trial"
$featureindex["08460AA2-A176-442C-BDCA-26928704D80B"] = "Search Server 2010"

$featureindex["84902853-59F6-4B20-BC7C-DE4F419FEFAD"] = "Project Server 2010 Trial"
$featureindex["ED21638F-97FF-4A65-AD9B-6889B93065E2"] = "Project Server 2010"

$featureindex["926E4E17-087B-47D1-8BD7-91A394BC6196"] = "Office Web Companions 2010"

#Clean method for getting all of the registry value names in a particular key
$path = "HKLM:\SOFTWARE\microsoft\Shared Tools\Web Server Extensions\14.0\WSS\InstalledProducts"

$regvalues = Get-Item $path | select -ExpandProperty property

# Cycle through all of the registry values

foreach ($i in $regvalues) {
   Write-Debug ("i: " + $i)
   $value = (Get-ItemProperty -Path $path).$i
   Write-Debug ("Value: " + $value)

   #For each value that we look at, are any of the corresponding SharePoint SKU GUIDs represented?
   foreach ($feature in $featureindex.Keys) {
     
      #If these are equal, then we have a particular SKU installed
      write-Debug ($value + " == " + $feature + " ?")
      if ($value -eq $feature) {
         write-output ($feature + " --> " + $featureindex[$feature] + " is installed")
      }
   }
}


There are third interesting pieces to the script. One is the easy way to iterate through the registry values contained in a particular key. The second is how to get the actual value (once you have the name). The third is that you can determine which SKUs are installed by using the InstalledProducts registry key created when SharePoint 2010 is installed.

To run the script, all that is needed is read access to the appropriate registry key and its values. 

2 comments:

  1. Does this work for a user? I have no (direct) access to the server it's running on.

    How is the script run. Do I paste it into Notepad? The DOS prompt? An API (what API?). From "Developer Tools" in IE (or Chrome/Firefox equivalent)? RegEdit? What?

    Not your fault of course, but why isn't there an easier way.

    ReplyDelete
    Replies
    1. no, you need to be at least a local administrator on the SharePoint server. You can copy and paste it into PowerShell (on the server) directly, or copy into notepad, save as a .ps1, and then run it (assuming that the script execution policy on the server allows this).

      Delete