Cross-Posted from: https://www.prajwaldesai.com/add-multiple-devices-to-sccm-collection-using-powershell/
Using PowerShell you can easily bulk add multiple devices to SCCM device collection. Using this guide, you will be able to import multiple devices into a target device collection using ConfigMgr PowerShell module.
There could be situations when you have to add a few hundred devices to a collection in SCCM. If it was a single device, you would use a directly query. However when you have got lot of computers, adding each of them would take a long time.
Thanks to PowerShell because it is a much easier and faster option to bulk add devices to SCCM device collection. We will accomplish our task using Add-CMDeviceCollectionDirectMembershipRule which adds a Direct Rule membership rule to a device collection. More info here.
Step 1 – Create a device collection in SCCM
- Open the SCCM Console. Go to Assets and Compliance > Overview > Device Collections.
- Click Create Device Collection in the top ribbon.
- The Create Device Collection Wizard opens. Specify a name of the new device collection and select the limiting collection. Click Next.
On the Membership Rules page, don’t add any rule. Click Next.
When you create a device collection without adding any resources, you get a warning. This collection has no membership rules… Click OK since we will be importing multiple devices into this device collection later.
On the Summary page, click Close.
On the Completion page, click Close.
Step 2 – Prepare the Computers List
After creating the target device collection, prepare a TXT file that contains all devices that you wish to add to device collection. In this example, the file name is List_computers.txt and contains the following devices.
Step 3 – Import the Computers using ConfigMgr Powershell cmdlets
On the top ribbon of the ConfigMgr console, click to the blue arrow and click Connect via Windows PowerShell.
Copy and paste the below command and don’t forget to change the text file location and the target collection name. Execute the command.
Get-Content "E:\Sources\Import\List_computers.txt" | foreach { Add-CMDeviceCollectionDirectMembershipRule -CollectionName "Computer List" -ResourceID (Get-CMDevice -Name $_).ResourceID }
After few minutes (It depends of the computers number), the device collection import task should be complete. You will find all the devices added to the device collection in SCCM.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.