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! 😎

Share
AlexIn Tech
Authors
SysOps Engineer | IT Consultant | IT Teacher
Alexis is a SysOps Engineer and IT teacher at ETML in Lausanne. Rooted in systems and infrastructure, he combines automation and custom development with a growing interest in AI to solve practical problems. He offers IT consulting, custom solutions, and hosting.