Hi, I am trying to find a way to wait for a vm customization to finish before moving on to the next script. This is for 1 vm only. I did see a script written by Lan Renouf I think, but I do not know how to modify the script to look at the status of just 1 vm instead of multiple. Any help would be appreciated! Here is the link for Alan's if anyone is interested:
http://blogs.vmware.com/vipowershell/2012/08/waiting-for-os-customization-to-complete.html'
Thanks in advance
Remove the RunAsync parameter
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That script is a function that you can call for 1 or more VMs.
.\WaitVmCustomization.ps1 -vmList $vms -timeoutSeconds 600
Just store the 1 VM in the $vms variable.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
$vms = 1..2 | % { New-VM -Name "WinXP-$_" -ResourcePool $vmhost -Template $template -Datastore $datastore -OSCustomizationSpec $spec }
Ok, so I would just change the 1..2 to 1 only?:
$vms = 1 | % { New-VM -Name "WinXP-$_" -ResourcePool $vmhost -Template $template -Datastore $datastore -OSCustomizationSpec $spec }
What does the piping to % mean?
Thanks Luc
That's an alias for the ForEach statement.
In fact you passing the numbers 1 and 2 to the code block of the ForEach loop.
Since you only want to do 1 VM there is no need to use the ForEach loop.
You can do
$vms = @(New-VM -Name "WinXP-$_" -ResourcePool $vmhost -Template $template -Datastore $datastore -OSCustomizationSpec $spec)
The @() construct is to make sure that the $vms variable will be an array, albeit with only 1 element.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am using:
$vms = @(New-VM -Name $VMName -VMHost $VMHost -Template $Template -Datastore $Datastore -OSCustomizationSpec $Spec -Confirm:$false -RunAsync)
and the value of $vms becomes "Clone_VM_Task" ... what am I missing?
Thanks Luc
Remove the RunAsync parameter
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks, that was it.