Here’s a pretty simple, quick script which quickly re-joins your machine to the domain. You run the script, the machine will reboot and you will then be able to login using your domain credentials again.
$psmachine = Get-WmiObject Win32_ComputerSystem
$psmachine.UnJoinDomainOrWorkGroup(“PASSWORD”, “USERNAME”, 0)
$psmachine.JoinDomainOrWorkGroup(“DOMAIN” , “PASSWORD”, “USERNAME”, $null, 3)
Restart-Computer -Force
Note: The USERNAME in both rows is just the username and NOT Domain\Username. Obviously passing a username and password in plain text is never a good thing. Frankly this is so small, I just copy and paste, create the script and run it from the machine in question as I need it. It’s quicker than joining the machine to the WORKGROUP and then re-joining to the domain, in my opinion!
Hope this is useful for some of you!