Today I needed to bulk remove multiple devices from multiple SCCM device collections.
Rather than do this manually I found a way to do this easily via powershell.
The command I am going to show you below will remove any devices with a direct membership in the device collection.
How To Bulk Remove Devices From SCCM Device Collection via Powershell
To bulk remove devices from a sccm device collection do the following steps
- RDP to your SCCM site server
- Open up the configuration manager console
- Open powershell via the console by clicking on the menu in the tool bar then click “Connect via powershell”
- In the powershell window type Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass then hit y and press enter
- Now lets get the information of the device collection we want to remove devices from. In the configuration manager console go to \Assets and Compliance\Overview\Device Collections\ and find the collection you want to use.
- For this guide I am going to use the “Test Collection” Device collection
- With the script we can use either the collection name “Which is Test Collection” or we can use the collection id
- To get the Collection id right click on the device collection and select properties. The collection id will be shown at the bottom of the window, Below my collection ID is NCS000B6
- Go back to the powershell window, and run the command you require
- Command 1 : Remove individual machines from the device collection (Replace %DEVICENAME% with your device you want to remove)
By Collection name : Remove-CMDeviceCollectionDirectMembershipRule -CollectionName “Test Collection” -ResourceName %DEVICENAME% -Force
By Collection id : Remove-CMDeviceCollectionDirectMembershipRule -CollectionID NCS000B6 -ResourceName %DEVICENAME% -Force - Command 2 : Remove device name pattern
By Collection name : Remove-CMDeviceCollectionDirectMembershipRule -CollectionName “Test Collection” -ResourceName Device* -Force
By Collection id : Remove-CMDeviceCollectionDirectMembershipRule -CollectionID NCS000B6 -ResourceName Device* -Force - Command 3 : Remove all devices
By Collection name : Remove-CMDeviceCollectionDirectMembershipRule -CollectionName “Test Collection” -ResourceName * -Force
By Collection id : Remove-CMDeviceCollectionDirectMembershipRule -CollectionID NCS000B6 -ResourceName * -Force - Now check the device collection and the required members should now be removed
If you want to learn more about this command you can see more information by Clicking Here

Hello, I am the owner of this site. I have 25+ years experience of IT. Check us out on the below social platforms.