Quantcast
Channel: VMware Communities : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 193198

Waiting for a template clone to finish deploying

$
0
0

I am working on an automated deployment script that creates VMs from a template. I've figured out most of the OS Customization stuff, even the NIC stuff! (Mostly.) But I'm stuck on getting my script to wait for a VM to finish cloning from the template.

 

I'm using the command:

 

New-VM -name $myTestServer -Template $myTestTemplate -VMHost $myVMhost -OSCustomizationSpec $mySpec -datastore $myDatastore

 

I can then see in vCenter that the machine is cloning, with a progress bar. However, the command doesn't wait for this; it just moves on.

 

I tried:

 

$vmCloneTask = New-VM -name $myTestServer -Template $myTestTemplate -VMHost $myVMhost -OSCustomizationSpec $mySpec -datastore $myDatastore -RunAsync

Wait-Task -task $vmCloneTask

 

That didn't work either; the task is treated as being complete and the script continues immediately.

 

What's interesting is that the next command is "Start-VM $myTestServer". Instead of erroring out, it actually waits until the machine is done cloning and then starts it. So, in practice, I'm getting the functionality I'm looking for... but it doesn't seem like the right way to do it.

 

Any suggestions? PowerCLI 5.0.0 build 3501, Powershell 2.0, vCenter Server 5.0.0 build 755629, ESX 4.1.0 build 702113.

 

Thanks,

 

Josh


Viewing all articles
Browse latest Browse all 193198

Trending Articles