Joining Workgroup using powershell fails if domain controller cannot be reached

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.

1
задан 4 March 2019 в 21:27
1 ответ

Я не уверен, работает ли это, но вы можете попробовать, используя:

Remove-Computer -ComputerName "Server01" -UnjoinDomainCredential Domain01\Admin01 -WorkgroupName "Local" -Restart -Force

Документация Microsoft: Remove-Computer

0
ответ дан 4 December 2019 в 03:12

Теги

Похожие вопросы