Blog

Getting the SharePoint On-Prem Farm GUID

Raphael Meng

How to read the farm GUID with one line of PowerShell.

Every on-premises SharePoint farm has exactly one globally unique identifier – the Farm GUID. It identifies the farm towards product keys, support diagnostics, and anything else that needs to tell two farms apart. This post shows the quickest way to read it.

The one-liner

Open the SharePoint Management Shell and type:

(Get-SPFarm).Id.Guid

That is all. The output is a single GUID, for example 3b2f9c8e-1a4d-4e7f-9c2a-8f1d6b5e4a3c. It is stable for the lifetime of the farm – the value survives patching, service restarts and even farm backups/restores, because it is stored in the configuration database.

What actually happens

The three parts of the one-liner, from the inside out:

  1. Get-SPFarm – returns the farm object (Microsoft.SharePoint.Administration.SPFarm) for the local farm, resolved via the configuration database the server is joined to.
  2. .Id – the SPGuid property of the farm: the identity created when PSConfig first provisioned the farm.
  3. .Guid – renders the SPGuid object as the familiar dashed hexadecimal string. (.Id alone would print the same value, but the explicit .Guid documents the intent.)

Alternative: the configuration database

The same GUID is stored in the Objects table of the farm's configuration database (name typically SharePoint_Config). If the Management Shell is not at hand:

# T-SQL against the SharePoint_Config database
SELECT Id, ClassId, Name FROM Objects
  WHERE ClassId = 'D55ADC8D-EA9F-4BB0-B361-0FDD9F0B4E15'
    AND Properties IS NOT NULL

The row with that class ID is the farm object; its Id column is the Farm GUID. Reading the config database is read-only here – but prefer the supported PowerShell route whenever possible.

Related one-liners worth knowing

# Farm name and version
(Get-SPFarm).Name
((Get-SPFarm).BuildVersion).ToString()

# Servers joined to the farm
(Get-SPFarm).Servers | Select-Object Name, Role, Status

# The farm's configuration database
(Get-SPFarm).Database.Name

All of these run against the farm object, so they need no parameters – handy for inventory scripts that collect farm facts in one go.

Note: Get-SPFarm requires the SharePoint Management Shell (or a machine with Microsoft.SharePoint.dll registered). It must be run on a farm server with an account that has access to the configuration database – elevated (administrator) rights are not required, since the cmdlet only reads farm metadata.

Why the Farm GUID matters

We use the Farm GUID when registering a farm for product updates, when matching support tickets to the right environment, and when documenting multi-farm estates (staging vs. production). Two farms can share a name – the GUID is what never collides.

Verified: on our SharePoint 2019 reference farm, (Get-SPFarm).Id.Guid returns the identical value as the Objects row in the configuration database – one line, no round trips.
Bloch Engineering · SharePoint Support · Commands must be reviewed before execution in production.