VMware Cloud Community
nodice
Contributor
Contributor

Joining VMs to Domain using PowerCLI

Hey there,

I'm running the following script on a group of VMs within a vApp in an attempt to get them to join my domain:

$vms = Get-VM -Location vAppname

$vmUser = "Administrator"

$vmPass = "password"

foreach ($vm in $vms){

     $cmd = "wmic.exe /interactive:off ComputerSystem Where ""Name='%computername%'"" call JoinDomainOrWorkgroup AccountOU=""OU-Computers`;DC=mydomain';DC=net"" FJoinOptions=1 NAme="mydomain.net"" Password=""password"" Username=""user@mydomain.net""

Invoke-VMScript -VM $vm -ScriptType bat -ScriptText $cmd -GuestUser $vmUser -GuestPassword $vmPAss

}

This script runs through the VMs and I get "Method execution successful" each time.  The problem is that the script doesn't appear to do anything.  Even after reboot, all of the machines are still using local accounts on WORKGROUP.

Any advice would be greatly appreciated!

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership

Does the wmic command work when you execute it while logged on to such a VM (with the $vmUser account) ?

In other words, does the domain join succeed ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos