Melbourne, Australia
To be provided
Use Contact to message

SCCM Documentation – Summary of all Sites in current Hierarchy

Harmik Batth Tech's Blog

SCCM Documentation – Summary of all Sites in current Hierarchy

Lets have a look at SCCM script to get Summary of all Sites in current Hierarchy. Purpose is to get all the information on SCCM Sites section in Configuration Manager Console.

SCCM-Sites

It should cover Primary , Secondary sites, Child Primary Sites and CAS (Central Administration Site).

First of all, you can use normal powershell (without SCCM integration) or connect SCCM current site via Powershell (withSCCM integration)

If you happen to run normal powershell only, you will have to Import the SCCM Powershell cmdlets

Import-Module ($env:SMS_ADMIN_UI_PATH.Substring(0,$env:SMS_ADMIN_UI_PATH.Length – 5) + ‘\ConfigurationManager.psd1’) | Out-Null}

Next SCCM cmdlets need to be run from the SCCM drive

$SiteCode = Get-SiteCode

Set-Location “$($SiteCode):” | Out-Null

To get Information about all types of sites, use following command

SCCM Site Details

$SCCMsites = Get-CMSite

$CAS = $CMSites | Where-Object {$_.Type -eq 4}
$ChildPrimarySites = $CMSites | Where-Object {$_.Type -eq 3}
$StandAlonePrimarySite = $CMSites | Where-Object {$_.Type -eq 2}
$SecondarySites = $CMSites | Where-Object {$_.Type -eq 1}

SCCM-GetSites

Most important thing to notice here is “Type”, which will identify site as “Primary Site”, “Secondary Site”, “Child Site” or “CAS” etc

Type = 1, Site is a Secondary Site
Type = 2, Site is a Standalone Priamry Site
Type = 3, Site is a Child Primary Site
Type = 4, Site is a Central Administration Site

If you are an SQL Person and ding some SQL scripts then same information can be obtained from SCCM Database using following command

SELECT * FROM [CM_HSB].[dbo].[Sites]

SCCM-GetSites-SQL

Ok, now we have Brief details of SCCM site in a Hierarchy. It is time to get overview of these Sites.

Standalone Primary Site

$StandAlonePrimarySiteName = $StandAlonePrimarySite.SiteName
$StandAlonePrimarySiteCode = $StandAlonePrimarySite.SiteCode
$StandAlonePrimarySiteVersion = $StandAlonePrimarySite.Version

Apart from that one important thing to check for is CU Pack installed.

$SiteCULevel = (Invoke-Command -ComputerName $(Get-CMSiteRole -RoleName ‘SMS Site Server’).NALPath.tostring().split(‘\\’)[2] -ScriptBlock {Get-ItemProperty -Path registry::hklm\software\microsoft\sms\setup | Select-Object CULevel} -ErrorAction SilentlyContinue ).CULevel

Where “$(Get-CMSiteRole -RoleName ‘SMS Site Server’).NALPath.tostring().split(‘\\’)[2]” will provide SCCM Server FQDN Hostname

and “Get-ItemProperty ` -Path registry::hklm\software\microsoft\sms\setup | Select-Object CULevel”, will provide CU Level from SCCM Server Registry

Secondary Site

$SecondarySiteName = $SecondarySites.SiteName
$SecondarySiteCode = $SecondarySites.SiteCode
$SecondarySiteVersion = $SecondarySites.Version

Child Primary Site

$ChildPrimarySiteName = $ChildPrimarySites .SiteName
$ChildPrimarySiteCode = $ChildPrimarySites .SiteCode
$ChildPrimarySiteVersion = $ChildPrimarySites .Version

Central Administration Site

$CASSiteName = $CAS.SiteName
$CASSiteCode = $CAS.SiteCode
$CASSiteVersion = $CAS.Version

Lastly, from the Build Number, get the actual Description

https://blogs.technet.microsoft.com/configmgrdogs/2014/02/07/configmgr-2012-version-numbers/

or great article on BuildNumbers

https://buildnumbers.wordpress.com/sccm/

This is it, Now you have all the information required for SCCM sites as a high level details.

 

No Comments

Add your comment