Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $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
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement