how do i collect all systems with AD site -eq “Edmonton-Site” ?
I’d create collection with a query on that attribute and then pull members from that collection via Powershell.
Adam Bertram wrote:I'd create collection with a query on that attribute and then pull members from that collection via Powershell.
is there a query that i can run to see all ‘Active Directory Sites’ available?
Here’s the WQL:
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.ADSiteName = “Edmonton-Site”
You can start with WMI, which is the preferred way SCCM should be remotely queried. If you look at the SMS_R_SYSTEM class, it will return a lot of general client information.
Get-WMIObject -ComputerName ~SERVER~ -Namespace root\sms\site_~SITE~ -Class SMS_R_SYSTEM -Filter “ADSite = ‘Edmonton-Site’”
If you do have a large query, I’ve had WMI choke and die due to memory related issues (e.g. pulling information from SMS_R_SYSTEM for 30k+ clients). When you connect to the database, you want to look at the Views for the database which will have comparable information to WMI versus doing 4 SQL joins to get the information you are looking for with the standard databases. If you are using Powershell 3+ and the SCCM server is 2008+, you can also you Get-CIMInstance to get the data as Get-WMIObject is supposed to be deprecated.