I have a Windows machine that has been cloned and to keep it from overwriting DNS entries it has only port 3389 enabled. What I am currently doing is using the GUI to join a workgroup and then renaming the computer before re-joining the domain. This works when done through the GUI but when done via Powershell it fails to leave domain and join workgroup.
I was attempting to use:
Add-Computer -WorkGroupName MyWorkGroup
However this gives the error:
Add-Computer : Failed to unjoin computer from domain with the following error message: The specified domain either does not exist or could not be contacted.
I though perhaps running Powershell as the local Administrator might work, but that encountered the same error. I though maybe using the cached domain admin account might work, but also get the same error. I thought maybe specifying any or all of the Credential/LocalCredential/UnjoinDomainCredential parameters might help but that yielded no luck either.
It seems like there has to be a way to do this through Powershell that I am overlooking. Any advice is appreciated.