Szukaj na tym blogu

czwartek, 17 marca 2016

SCCM get collection members name and MAC address

$SiteServer = 'server'
$SiteCode = 'XXX'
$CollectionName = 'DeviceColl*'

$Collections = Get-WmiObject -ComputerName $SiteServer -Namespace  "ROOT\SMS\site_$SiteCode" -Class SMS_Collection | where {$_.Name -like "$CollectionName"}

foreach ($Collection in $Collections){
    $SMSClients = Get-WmiObject -ComputerName $SiteServer -Namespace  "ROOT\SMS\site_$SiteCode" -Query "SELECT * FROM SMS_FullCollectionMembership WHERE CollectionID='$($Collection.CollectionID)' order by name" | select *
    foreach ($SMSClient in $SMSClients){
        $ClientName = $SMSClient.Name
        $ClientMAC = (Get-WmiObject -Class SMS_R_SYSTEM -ComputerName $SiteServer -Namespace root\sms\site_$SiteCode | where {$_.Name -eq "$ClientName"}).MACAddresses
        $SMSClient.Name + ", " + $ClientMAC + ", " + $Collection.Name | out-file -append C:\list.txt
    }
}

Brak komentarzy:

Prześlij komentarz