PowerShell: Add Computers to SCCM Collection

PowerShell: Add Computers to SCCM Collection

For various reasons for example – Client OS deployment, Application Deployment match Organization OU structure with SCCM Device Collection or for any short team need for adding computer to Collection using Direct Membership method.

Below is the PowerShell command to read the computer names from text file and then add those computers to SCCM collection:

Text File – C:SCCMComputers.txt :

Computer01

Computer02

Computer03

Collection Name: “Abobe Photoshop”

$Computers = Get-Content C:SCCMComputers.txtforeach ($computer in $Computers) {Add-CMDeviceCollectionDirectMembershipRule -CollectionName "Adobe Photoshop" -ResourceID $(Get-CMDevice -Name $_.computer).ResourceID}

 

 

About The Author

Related posts

1 Comment

  1. Krishnareddy Kompale

    Hi sarvesh, I need powershell script to get list of same machines from 2 different collection.
    Thanks In Advance.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *