VMware Cloud Community
balsz
Contributor
Contributor

Delete AD Computer Account Based on Different Location DCs

I am looking for deleting the AD computer account by searching the Domain Controller of different locations and delete where it finds first. Because, when the server deployment rollback happens due to some failure with the existing AD plugin removal method it's not finding the AD computer (rollback happens quickly and the created AD computer not replicated across the locations within the time). We have vRA7.2 with AD plugin.

The below article helps for different domain. However, I am looking for searching different location domain controllers of the same domain.

Delete computer from AD by name

0 Kudos
4 Replies
daphnissov
Immortal
Immortal

I have observed this type of quirky behavior with the built-in AD plug-in. A much more robust option is the SovLabs AD module. I have never seen a deployment fail because of issues within that one.

0 Kudos
balsz
Contributor
Contributor

Ok. Thank you!

0 Kudos
FreddyFredFred
Hot Shot
Hot Shot

I had a similar issue and had to write my own code to target a specific domain controller rather than using the built-in workflows. I'm using vro, not vra, so maybe there's a difference but here's what I did:

Add all your domain controllers in vro then make your own scriptable task step to find the domain controllers and loop them through/target a specific one. This little piece of code, not pretty but it works, pulls all my domain controllers, matches against a specific one, then runs a search. After that I can take my ADcomputer and pass it to the destroyElementRecursive action and delete the computer account on the specified domain controller. In my case I know what location i'm working against so I know what DC I want to target but in your case I guess yo uwould just put the code for the getComputerAD into the for loop perhaps.

var allAdHosts = AD_HostManager.findAllHosts();

var myDCtoUse = "abc001";

//pick the one we want to target

for (i = 0; i < allAdHosts.length; i++) {

    if (allAdHosts[i].name == myDCtoUse){

        foundAdHost = allAdHosts[i].id;

    }

}

//get AD host object from the id

var adDc = AD_HostManager.findHost(foundAdHost);

ADcomputer=ActiveDirectory.getComputerAD(computerName,adDc);

0 Kudos
balsz
Contributor
Contributor

Thank you Freddy! I will explore this option and update here.

0 Kudos