# Adding multiple machines to single collection (Direct membership collection)
$Sitecode = "SMS"
# add the site code
$PathToSCCMModule = "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1"
Import-Module $PathToSCCMModule
$Computers = get-content "C:\users\USER_Name\Desktop\Testmachine.txt"
cd "$Sitecode`:"
Foreach ($Computer in $Computers)
{ Add-CMDeviceCollectionDirectMembershipRule -CollectionName "WIndows 7 collection" -ResourceId ((Get-CMDevice -name $Computer).ResourceID) }
#Collection name in yellow WIndows 7 collection
$Sitecode = "SMS"
# add the site code
$PathToSCCMModule = "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1"
Import-Module $PathToSCCMModule
$Computers = get-content "C:\users\USER_Name\Desktop\Testmachine.txt"
cd "$Sitecode`:"
Foreach ($Computer in $Computers)
{ Add-CMDeviceCollectionDirectMembershipRule -CollectionName "WIndows 7 collection" -ResourceId ((Get-CMDevice -name $Computer).ResourceID) }
#Collection name in yellow WIndows 7 collection
No comments:
Post a Comment