从服务器列表中获取SCCM集合信息



我需要从150台服务器的列表中获取SCCM集合信息,以确定每个设备属于哪个部署集合。我可以很容易地列出集合中的所有设备,但不能反过来。下面列出了除他们所属的集合之外的所有其他内容。

获取内容"C: \Temp\ServerList.txt"|foreach{Get-CMDevice}|导出Csv-Force-NoTypeInformation";c: \temp\sccmcollectioninfo.csv">

我认为这不能单独使用commandlet来完成,但您可以使用WMI来代替:

$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")

从那里,您可以将名称(或更好的resourceid(输入到commandlets中,以便再次进行部署。如果您有足够的访问权限,那么在SQL中查询数据库会更快(v_FullCollectionMembership和v_Collection是相应的视图(。

最新更新