Windows Server 2016 Server Core the machine is already joined to the domain
In working a lot recently with Windows Server 2016 Core in a lab environment, I ran into an issue after rolling back a snapshot on a Hyper-V Server Core install. ย The snapshot rollback of course broke the computer account/domain relationship with the Windows Server 2016 Server Core install. ย However, I thought I would simply be able to disjoin the domain and rejoin to reset the computer account. ย When attempting to do that, I received the error with Windows Server 2016 Server Core the machine is already joined to the domain.
Windows Server 2016 Server Core the machine is already joined to the domain
The problem as well as that I couldn’t even back the Server Core install off to a Workgroup either. ย It still tries to hit the domain when joining a workgroup. ย Any domain join/disjoin action leads to theย the machine is already joined to the domain error. ย Part of my issue was the snapshot of the Hyper-V Server Core host was of a different computer name – the default, automatically generated computer name.
As you can see below, the orphaned computer account,ย H2, is there, however, communication with the domain is broken AND the rolled back snapshot is of a different name.
Let’s see if with some Posh Kung Fu, we can force the removal of the computer from the domain. ย Using the script below, still ran into the issue of it knowing the current computer name was different than the domain account.
remove-computer -computername "H2","localhost" -unjoindomaincredential TESTLABadministrator -Workgroup "WORKGROUP" -Restart -Force
Ok, so let’s try to use the current autogenerated name and see what happens. ย This time we receive a different error because the current computer name cannot be mapped to a computer account in the domain. ย So are we stuck?
Let’s see what happens when I simply create a shell computer account of the same name –ย WIN-NOSNEUISPF1 in the domain and then try the disjoin.
So, now we have the account created.
Now, I am going to use the sameย remove-computer commandlet and also specifying the autogenerated computer name now that we have a dummy computer account in AD.
Success!
Amazingly, just simply creating a computer account that it could see with the same name allowed us to disjoin the domain.
Thoughts
If you run into the error withย Windows Server 2016 Server Core the machine is already joined to the domain, then most likely you can simply stage a computer account in the domain to reflect what the Windows Server 2016 Server Core thinks the name should be, and then you can disjoin the computer from the domain and then rejoin. ย This was quite a lot of grief just to resync with the domain but this simple computer account trick seems to work like a charm.