How To Remove a Device From a Collection in SCCM

Jason Barrett Jason Barrett | | Device Collection

In this article I will show you hot to remove a device from a collection in SCCM, I will show you how to do it manually, and how to remove multiple devices using powershell.

Note : You can only remove devices from a collection if they were added by a direct rule.

If the devices were added by a query rule you will need to create an exclude collection and apply to the device collection which I will show you below.

Remove Devices From Collection Manually

This step will only work on SCCM collections that have devices added with direct membership.

To remove a device from a SCCM device collection manually follow these steps

  1. Log on to the SCCM server
  2. Open the Microsoft Configuration Manager Console
  3. Go to \Assets and Compliance\Overview\Device Collections\
  4. Right click on the required collection and select properties
  5. Click the “Membership Rules” tab
  6. Highlight each device you want to remove
  7. Click delete
    remove device from sccm collection
  8. Click Apply
  9. Click Ok

The devices will now be removed from the collection.  In my experience it will take a few hours for the client to pick up the change that it has been removed from the collection.

Remove Device From Collection Using Powershell

Using the powershell command Remove-CMDeviceCollectionDirectMembershipRule we can remove multiple devices from SCCM collections as per the requirement which I will show below.

To remove devices from sccm device collections with powershell follow these steps

  1. Log on to the SCCM site server
  2. Open up the configuration manager console
  3. Open powershell via the console by clicking on the menu in the tool bar then click “Connect via powershell”
    sccm console powershell
  4. In the powershell window type Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass then hit y and press enter
    set execution policy in powershell
  5. 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.
  6. For this guide I am going to use the “Test Collection” Device collection
    test sccm device collection
  7. With the script we can use either the collection name “Which is Test Collection” or we can use the collection id
  8. 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
    collection id

Now we have the collection id we can run one of the below commands

Remove Individual Machines

To remove individual machines use one of the below commands.

The below command uses the device collection name, replace “Test Collection” with the required collection, also replace %DEVICENAME% with the device you wish to remove.

1
Remove-CMDeviceCollectionDirectMembershipRule -CollectionName “Test Collection” -ResourceName %DEVICENAME% -Force

The below command uses the device collection id, replace “NCS000B6” with the required collection id, also replace %DEVICENAME% with the device you wish to remove.

1
Remove-CMDeviceCollectionDirectMembershipRule -CollectionID NCS000B6 -ResourceName %DEVICENAME% -Force

Remove Machines Using Wildcard

We can remove multiple devices using a wildcard command as per below.

Replace Test Collection or NCS000B6 with your device collection, then replace Device* with the required device name

1
Remove-CMDeviceCollectionDirectMembershipRule -CollectionName “Test Collection” -ResourceName Device* -Force
1
Remove-CMDeviceCollectionDirectMembershipRule -CollectionID NCS000B6 -ResourceName Device* -Force

Remove All Devices

To remove all devices from a collection you can use the below powershell command.

1
Remove-CMDeviceCollectionDirectMembershipRule -CollectionName “Test Collection” -ResourceName * -Force
1
Remove-CMDeviceCollectionDirectMembershipRule -CollectionID NCS000B6 -ResourceName * -Force

Remove Devices From Collection Using Query Rule

If a sccm device collection is using a query rule you can not remove individual devices using the above commands.

Below I will show you how to create a exclude device collection and apply it.

  1. Log on to the SCCM server
  2. Open the Microsoft Configuration Manager Console
  3. Go to \Assets and Compliance\Overview\Device Collections\
  4. Create A new device collection that will be used to put the devices in you want to exclude from a collection
  5. Add the devices you want to exclude in to this collection
  6. Click ok to save the settings
  7. Find the sccm device collection you want to exclude devices from, right click on it and select properties
  8. Click “Membership Rules” tab
  9. Click Add Rule
  10. Select Exclude Collection
  11. Select the collection you created in step 4
  12. Click ok
  13. The devices will now be excluded from the query collection