Quick PowerShell Script to list all Primary and Secondary sites with Site Version

Just a quick example for listing all your sites – run this against your central site.

#replace MySiteServer with central site server name, 
#and LAB with site code
$sites = Get-Wmiobject SMS_Site -computer MySiteServer -namespace root\sms\site_LAB
#display information to the screen
$sites | select-object ServerName, SiteCode, Status, Type, Version, BuildNumber, ReportingSiteCode | sort-object ReportingSitecode
#or if you'd like, export to a .csv
$sites | select ServerName, SiteCode, Status, Type, Version, BuildNumber, ReportingSiteCode | sort ReportingSitecode | export-csv c:\temp\ConfigMgrSites.csv -notypeinformation

Greg

How To: List all servers used by your ConfigMgr Infrastructure

Here’s a quick PowerShell script to show all servers used in your ConfigMgr Hierarchy:

$myServers  = get-wmiobject  SMS_SystemResourceList `
   -namespace root\sms\site_LAB –computer LABServer
$myServers | select-object servername -unique `
   | sort Servername | out-gridview

You can alter that script a little to show all Roles for each server:

$myServers  = get-wmiobject  SMS_SystemResourceList `
    -namespace root\sms\site_LAB –computer LABServer
$myServers | select-object servername, RoleName  `
    | sort Servername | out-gridview

To run these in your environment, launch in PowerShell with proper rights to query your hierarchy, and replace “LAB” with your Central site ConfigMgr Site Code, and replace LABServer with your Central site server name.

Happy Scripting,

Greg

ramseyg@hotmail.com