Script to delete duplicate computers from sccm daily basis

suport.teche 1 Reputation point
2021-09-17T17:12:46.62+00:00

Hi ,

is there any way to delete duplicate devices from SCCM collection(from DB as well) . if yes please provide a script or method / procedure. i will schedule it as task on my server. Please help me on this matter.

Best Regards,
Suport.teche

Microsoft Configuration Manager
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Garth Jones 1,656 Reputation points
    2021-09-17T17:39:34.393+00:00

    There is no support method to delete devices out the CM DB. At best you can delete them from CM and wait for CM to delete them from the db, which happens ever few days. Look at powershell to delete them from CM.

    0 comments No comments

  2. Jason Sandys 31,186 Reputation points Microsoft Employee
    2021-09-17T20:07:16.757+00:00

    What do you mean by "duplicate devices"? This is where you should be focusing as this is not normal.

    0 comments No comments

  3. AllenLiu-MSFT 42,511 Reputation points Microsoft Vendor
    2021-09-20T07:28:13.287+00:00

    Hi, @suport.teche
    Thank you for posting in Microsoft Q&A forum.

    You may create a collection with below query used to find the computer names appear twice or more with different resource ID,GUID etc

    select sys.ResourceID,sys.ResourceType,sys.Name,sys.SMSUniqueIdentifier,  
    sys.ResourceDomainORWorkgroup,sys.Client from SMS_R_System as sys  
    full join SMS_R_System as sys1 on sys1.ResourceId = sys.ResourceId  
    full join SMS_R_System as sys2 on sys2.Name = sys1.Name  
    where sys1.Name = sys2.Name and sys1.ResourceId != sys2.ResourceId  
    

    You can delete all these records manually or create a powershell script with schedule to empty the collection. This way , you loose the inventory of active computers but they send back in the next inventory cycle.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  4. suport.teche 1 Reputation point
    2021-09-21T16:38:33.453+00:00

    @ Jason : - Devices with same name , have separate collection , i need script to delete machine from the collection every day..

    @ AllenLiu : - I have the query , i am looking for script to schedule the task everyday.

    any help !!

    Best Regards,
    suport.teche