PowerShell & SCCM 2012

This topic contains 4 replies, has 3 voices, and was last updated by  Rob Simmers 3 years, 2 months ago.

  • Author
    Posts
  • #16671

    Ian
    Participant

    how do i collect all systems with AD site -eq "Edmonton-Site" ?

  • #16674

    Adam Bertram
    Moderator

    I'd create collection with a query on that attribute and then pull members from that collection via Powershell.

  • #16676

    Ian
    Participant

    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?

  • #16677

    Adam Bertram
    Moderator

    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"

  • #16681

    Rob Simmers
    Participant

    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 [b]~SERVER~[/b] -Namespace root\sms\site_[b]~SITE~[/b] -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.

You must be logged in to reply to this topic.