Introduction

In this article, we will show How to detect the SharePoint 2016 Edition and the Farm Build Number via Server Side Object Model - C#.


Get SharePoint 2016 Edition

The below function "Get_SPEdition" is used to detect the SharePoint 2016 Edition, based on the installed product SKU it shows the corresponding edition.

In case, it'

  • 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.
public string Get_SPEdition()
{
    try
    {
        string edition = "";
        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;
                }
            }
        });
 
        return edition;
    }
    catch (Exception)
    {
        return "An error occurred! Make sure that\r\n- The SharePoint is installed";
    }
}


Get SharePoint 2016 Build Number

The below function "Get_SPVersion" is used to detect the Farm Build Number.

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


Output

(Test1) You have SharePoint 2016 installed, the result should look like


(Test2)
You don't have SharePoint 2016 installed but you have other SharePoint version, the result should look like


(Test3)
You don't have installed any SharePoint version, the result should look like


Applies To

  • SharePoint 2016.

Download

  • Download the source code from TechNet Gallery "Detect SharePoint 2016 Edition Solution".
  • 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 this article, we have explained how to detect the SharePoint 2016 Edition and the Farm Build Number via Server Side Object Model - C#.

See Also

Back to Top