D. BamBam
D. BamBam

Reputation: 5

Get SCCM Collection Info from List of Servers

I need to get SCCM collection info form a list of 150 servers to figure out what deployment collections each device belongs to. I can easily list all devices from a collection but not the other way. The below gets everything else but what collections they are members of.

Get-Content "C:\Temp\ServerList.txt" | foreach {Get-CMDevice} | Export-Csv -Force -NoTypeInformation "c:\temp\sccmcollectioninfo.csv"

Upvotes: 0

Views: 1456

Answers (1)

Syberdoor
Syberdoor

Reputation: 2619

I think this can not be done with the commandlets alone, but you can just use WMI instead:

$DeviceName = "your device"
$SiteServer = "site server"
$SiteCode ="site name"
(Get-WmiObject -ComputerName $SiteServer -Namespace root/SMS/site_"$SiteCode" -Query "SELECT SMS_Collection.* FROM SMS_FullCollectionMembership, SMS_Collection where name = '$DeviceName' and SMS_FullCollectionMembership.CollectionID = SMS_Collection.CollectionID")

From there you can input the name (or better resourceid) into the commandlets for deployments again. If you have enough access rights it would be even faster to query the db in SQL instead (v_FullCollectionMembership and v_Collection are the corresponding views).

Upvotes: 0

Related Questions