VMware: Failed to leave the domain . The user or group named ‘\esx^admins’ does not exist.

Sometimes when ESXi loses its trust relationship with Active Directory, you cannot log in with your AD account, and attempts to remove the ESXi server from AD result in an error:

Failed to leave the domain <Domain Name>. The user or group named ‘<AD>\esx^admins’ does not exist.

Solution:

Create a local group called esx^admins:

/usr/lib/vmware/busybox/bin/busybox addgroup DOMAIN\\esx^admins

(Change DOMAIN to be Netbios name of AD, and note the double \)

Repeat for any other AD based group names you have assigned permission to within the ESXi host.

Remove from the domain, either via ESXi or vCenter (preferred)

Remove the temporary local group(s):

/usr/lib/vmware/busybox/bin/busybox delgroup DOMAIN\\esx^admins

Add the ESXi Host back into the domain via ESXi or vCenter (preferred).

If it fails to rejoin after a long delay, delete the Computer object for the ESXi Host from AD.