Monday, May 14, 2018

Adding Single machine to multiple collection (Direct membership rule to the collection)

# 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.

No comments:

Post a Comment

SCCM Application Deployment Tool

SCCM Application Deployment Tool Streamlining SCCM Application Deployments: Introducing the SCCM Application Deployment Tool. In the realm o...