SharePoint 2016 SKU: Get SharePoint Edition Using C#

Detect SharePoint Edition Using CSharp

In this article, we will learn how to get SharePoint edition and the SharePoint farm build number programmatically using C#.

You might also like to read How to Get SharePoint Edition PowerShell?


Get SharePoint Edition Using C#

Detecting the SharePoint Edition programmatically using C# is not just a line of code as detecting the SharePoint Build Number!

To detect the SharePoint 2016 Edition, it requires knowing the corresponding SKU that is is a unique set of characters identification code for a particular product/service.

SharePoint 2016 Editions based on Product SKU

  • 5DB351B8-C548-4C3C-BFD1-82308C9A519B, So The Installed SharePoint Edition is SharePoint 2016 Trail.
  • 4F593424-7178-467A-B612-D02D85C56940, So The Installed SharePoint Edition is SharePoint 2016 Standard.
  • 716578D2-2029-4FF2-8053-637391A7E683, So The Installed SharePoint Edition is SharePoint 2016 Enterprise.

Based on the installed product SKU, you can detect the corresponding SharePoint 2016 Edition using C# as the following:

SPSecurity.RunWithElevatedPrivileges(delegate() {
  var editionguid = SPFarm.Local.Products;
  foreach(var item in editionguid) {
    switch (item.ToString().ToUpper()) {
      // SharePoint 2016
    case "5DB351B8-C548-4C3C-BFD1-82308C9A519B":
      edition = "SharePoint Server 2016 Trail.";
      break;
    case "4F593424-7178-467A-B612-D02D85C56940":
      edition = "SharePoint Server 2016 Standard.";
      break;
    case "716578D2-2029-4FF2-8053-637391A7E683":
      edition = "SharePoint Server 2016 Enterprise.";
      break;
    default:
      edition = "The SharePoint Edition can't be determined.";
      break;
    }
  }
});

Get SharePoint Farm Build Version Using C#

Besides the above code, you can also get the SharePoint Farm Build Version Using C# as below:

public string Get_SPVersion() {
  try {
    return SPFarm.Local.BuildVersion.ToString();
  }
  catch(Exception) {
    throw;
  }
}

Download Get SharePoint Edition Solution

You can download the full solution to get SharePoint Edition and the build number from GitHub at Get SharePoint Edition Programmatically

Get SharePoint Edition Using C#

In case, you need to run only the execution file, you should get it at this location “\SharePoint 2016 Edition Detection\bin\Debug\SharePoint_Edition_Detection.exe”


Conclusion

In conclusion, we have provided a simple solution developed by C# to determine which SharePoint Edition has been installed.

See Also

Leave a Reply

Scroll to Top