PowerShell / ConfigMgr: Retrieve List of Client Names by Collection ID
Posted by Trevor Sullivan on 2011/11/01
Here’s a simple PowerShell script that you can use to retrieve a list of system names based off of a collection ID in Microsoft System Center Configuration Manager (SCCM / ConfigMgr) 2007. This has not been tested against collections that contain anything except system resources (computers objects in SCCM). Use at your own risk.
# Variables $SiteCode = '123'; $SccmServer = 'sccmserver.mydomain.com'; $CollectionID = '12345678'; # Commands to retrieve client name list $ClientList = Get-WmiObject -ComputerName $SccmServer ` -Namespace "root\sms\site_$SiteCode" ` -Class SMS_FullCollectionMembership ` -Filter "CollectionID = '$CollectionID'" ` -Property @('Name'); $ClientNames = $ClientList | Select-Object Name $ClientNames