Once we know that the primary servers are installed in our environment, the next step is to identify the site servers that are installed in our environment. The following code demonstrates how to get the list of all site servers that are installed in our Configuration Manager environment:
$CentralSiteCode = "ABC" $CentralSiteProvider = "SCCMCAS" $SiteRoles = Get-WmiObject -ComputerName $CentralSiteProvider -Namespace root\sms\site_$CentralSiteCode SMS_SystemResourceList $Servers = new-object System.Collections.ArrayList $ArrServers = new-object System.Collections.ArrayList Foreach ($item in $SiteRoles) { $StrFQDN = ($item.ServerRemoteName).ToUpper() $ArrServers.Add($StrFQDN) - } $Servers = $arrServers | sort | select –uniq
Upon successful execution of the code, the $Servers
variable will have a list of all the site servers installed in the environment.