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
$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