Posted by: Richard Siddaway
PowerShell v2, Windows 2008 R2
I was creating a new virtual machine and decided to test the JoinDomainOrWorkgroup method of the Win32_ComputerSystem class
The syntax is relatively straight forward
$comp = Get-WmiObject Win32_ComputerSystem
$password = "Gu3ssWh4t"
$user = "Manticore\Richard"
$domain = "Manticore"
$comp.JoinDomainOrWorkgroup($domain, $password, $user, $null, 3)
It kept failing with a 1316 return code. Couldn’t find a reference to that so eventually tried using Add-Computer. That told me the computer account already existed. OOOPS. Got the name wrong. One quick rename later and we’re in business