Last day’s very busy with a small DevOps project in our company. Automating “bare metal deployment” of new Hyper-V Servers. We deploy the software with a combination of MDT and the brand new HP (finally) PowerShell commands.
During the step of renaming and joining the new server we faced the following error:
Computer failed to join domain ” from its current workgroup ‘WORKGROUP’ with following error message: No mapping between account names and security IDs was done.
After some troubleshooting we found a solution, by adding the two options: JoinWithNewName and AccountCreate
Renaming computer PowerShell and Joining a domain with PowerShell
1 2 3 4 5 6 7 8 9 10 11 12 |
$Servername = "NewServerName" $cred = get-credential $domainname = "robvit.local" #Rename computer PowerShell Rename-Computer -ComputerName $env:COMPUTERNAME -NewName $ServerName #A small PowerShell Sleep Sleep -s 10 #Join Domain PowerShell Add-Computer -DomainName $DomainName -Credential $cred –Options JoinWithNewName,AccountCreate -force |
Thanks for this post! I tried the parameter -NewName first, but it gave me an error. Afterwards I tried using -Options JoinWithNewName, but it gave me the error that you described.
I added “AccountCreate” as an option and it worked! It’s funny that Microsoft Documentation for the command Add-Computer mentions that AccountCreate is not needed but it won’t work otherwise!
Thanks for your confirmation it works with this “workaround”.
Greetings, Robvit
Thanks a ton, this fixed my add to domain script as well…
Much appreciated. Was going a bit nuts trying to figure this out!