VMware Cloud Community
tickermcse76
Contributor
Contributor

Scripting VM template deployment and configuration

I'm running a script that deploys new VM's from a template based on information supplied in a CSV file.

It takes anywhere from 10-15 minutes for New-VM to deploy a template.  The next step is calling Set-VM to set the vCPU and RAM.  What I've noticed is after New-VM is called, the PowerCLI console will proceed to the next step of Set-VM, but it will show 0% complete because the template has not completed deployment yet.  After running through the deployment of ~80 VM's it failed once.  The Set-VM command failed stating the target VM did not exist.  I believe the issue was Set-VM continued; does it have a timeout value?  It's critical that the process can run unattended and so I'd to reduce the chance of that happening again.  Do I need to implement some form of check that the VM is deployed before continuing to the Set-VM step?  Are there any best practices for those who have done it before?

One solution that I thought of was using Get-Task to check for template progress and wait for that to complete before proceeding to Set-VM.  But I'm not sure how to get the exact task ID of the template deployment job. 

Tags (1)
0 Kudos
0 Replies