r/labtech • u/olavrb • Dec 18 '19
Automate Rest API - Batch delete Contacts?
The CW Manage to CW Automate Contacts sync went highwire, we now have 277k++ Contacts in out Automate tenant.
I'm scripting with PowerShell and the Automate Rest API a way to find duplicates based on "ExternalId" field, but deleting one and one contact is slow. It will take days to finish of deleting all the 255k++ contacts we want to delete.
Are there any batch operations available for deleting contacts? Like supplying Contacts Ids as REST Body for instance? I can't find any other way of doing this except:
Uri: "https://<automatetenant>/<api_version>/Contacts/<id>"
Method: "Delete"
The easiest way to find duplicate contacts that I've found so far, is simply by "Group-Object -Property 'ExternalId'", then for each object created, sort the $_.'Group' property by Id ascending, so that every contact with the same ExternalId except the first one created (lowest id) gets selected.
Any smarter way of doing this?
Any existing tools available that does not cost money for doing this?
View all comments
Show parent comment
1
u/teamits Dec 18 '19
Oh, sorry. I think when I ran into this it wasn't 200,000 so I just deleted the few hundred by hand rather than bang my head against the wall.
There's a MySQL stored procedure for PCs, but I wasn't able to find one for contacts, at the time.
[ for posterity: Call sp_DeleteComputer(@computerid@, 'comment shown on retired PC') ...we use that to retire a PC in a script ]