Find the SCCM (MECM) Site Code Using PowerShell

21 Sep, 2022·
AlexIn Tech
AlexIn Tech
· 1 min read

Find the SCCM (MECM) Site Code Using PowerShell

The SCCM (MECM) site code information is stored in WMI, so we can retrieve it using PowerShell.

Here is the command to use:

$SCCMSiteCode = $([WmiClass]"\\localhost\ROOT\ccm:SMS_Client").GetAssignedSite()
$SCCMSiteCode.sSiteCode

If you want to learn more about the SMS_Client method, check out this link:

https://msdn.microsoft.com/en-us/library/jj874307.aspx

Enjoy! 😎

AlexIn Tech
Authors
SysOps Engineer | IT Teacher
Versatile IT Engineer with a dual specialization in System Engineering and Management, AlexIn Tech teaches IT to CFC apprentice IT specialists at ETML, the Technical School of Lausanne 🇨🇭. Passionate about IT, innovation, and knowledge sharing, he shares his discoveries and learnings here to inspire new generations.