# Adding Single machine to multiple collection (Direct membership rule to the collection)
$Sitecode = "SMS"
# add the site code
$PathToSCCMModule = "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1"
Import-Module $PathToSCCMModule
$Collections= get-content "C:\users\USER_Name\Desktop\Collectionlists.txt"
cd "$Sitecode`:"
Foreach ($Collection in $Collections)
{ "$Collection"; add-CMDeviceCollectionDirectMembershipRule -CollectionName $collection -ResourceId ((Get-CMDevice -name "WINDOWS7TESTMachine").ResourceID) }
#Test machine name WINDOWS7TEST which is being added to the collections list txt file.
$Sitecode = "SMS"
# add the site code
$PathToSCCMModule = "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1"
Import-Module $PathToSCCMModule
$Collections= get-content "C:\users\USER_Name\Desktop\Collectionlists.txt"
cd "$Sitecode`:"
Foreach ($Collection in $Collections)
{ "$Collection"; add-CMDeviceCollectionDirectMembershipRule -CollectionName $collection -ResourceId ((Get-CMDevice -name "WINDOWS7TESTMachine").ResourceID) }
#Test machine name WINDOWS7TEST which is being added to the collections list txt file.
No comments:
Post a Comment