Skip to content

Instantly share code, notes, and snippets.

@Nora-Ballard
Created February 15, 2014 13:31
Show Gist options
  • Save Nora-Ballard/9019382 to your computer and use it in GitHub Desktop.
Save Nora-Ballard/9019382 to your computer and use it in GitHub Desktop.
function Get-SCCMSiteMode($ComputerName)
{
if ( $(Get-Service -Name CcmExec -ComputerName $ComputerName -ErrorAction SilentlyContinue) )
{
try { $CCM_ClientSiteMode = Get-WmiObject -Namespace 'ROOT\ccm' CCM_ClientSiteMode -ComputerName $ComputerName -EA SilentlyContinue }
catch { $CCM_ClientSiteMode = $NULL}
if ($CCM_ClientSiteMode)
{
$SiteModes = @{
'0' = 'Unknown'
'1' = 'Mixed Mode'
'2' = 'Native Mode'
}
if ($CCM_ClientSiteMode.SiteMode.ToString() -eq $null) { $SiteModeText = 'Not Available' }
else { $SiteModeText = $SiteModes[$CCM_ClientSiteMode.SiteMode.ToString()] }
}
else
{
Write-Warning "Could not connect to WMI class CCM_ClientSiteMode on '$ComputerName'."
$SiteModeText = 'Not Available'
}
}
else
{
Write-Warning "Could not find 'CcmExec' service. SCCM Client is not available."
$SiteModeText = 'No Client'
}
Write-Verbose "SCCM SiteMode:`t$($SiteModeText)"
Write-Output $SiteModeText
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment