VMware Cloud Community
dwchan
Enthusiast
Enthusiast
Jump to solution

What's a good way to monitor a VM template creation

I am building a script for a greenfield deployment.  Based on one input, it will mount the required generic ISO and create the appropriate VM templates and some of the typical post-installation (e.g. VMware Tool, VMware OSOT, Horizon components, etc).  I got the OS to install, VMware tool installed, and a reboot.  However, from a script point of view, what's a good way to tell the script that the OS is installed after the VM is powered on for the first time?  I can use a timeout, but that is not very reliable at all.  Unlike a VM build from a template where I can monitor the VC message like guest customization, from VC point of view, the VM just power on, that's it.  Any suggestion would be greatly appreciated 

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

If there is no customization, there will of course be no corresponding event.

If you have VMware Tools installed on the VM, you can wait for the GuestOperationsReady property  in the GuestInfo object to become $true.
That indicates the moment you can start doing Invoke-VMScript cmdlets against that VM.
That is what I normally do, see for example line 128 in my Install-CloudInitVM in my Cloud-Init – Part 3 – Photon OS post.


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

View solution in original post

0 Kudos
7 Replies
LucD
Leadership
Leadership
Jump to solution

Most of the Guest OS customisation methods leave an indication that the customisation is complete.
You didn't say which method you are using.


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

0 Kudos
dwchan
Enthusiast
Enthusiast
Jump to solution

I am at the VM template creation phase, so no guest customization is being used but I do see where you are going.  So there is nothing I can see is reporting back on VC related to guest creation, other than VM power on

0 Kudos
LucD
Leadership
Leadership
Jump to solution

If there is no customization, there will of course be no corresponding event.

If you have VMware Tools installed on the VM, you can wait for the GuestOperationsReady property  in the GuestInfo object to become $true.
That indicates the moment you can start doing Invoke-VMScript cmdlets against that VM.
That is what I normally do, see for example line 128 in my Install-CloudInitVM in my Cloud-Init – Part 3 – Photon OS post.


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

0 Kudos
dwchan
Enthusiast
Enthusiast
Jump to solution

Fantastic, I will give that a try as part of my automated build does include the VMware tool

0 Kudos
dwchan
Enthusiast
Enthusiast
Jump to solution

That did the trick, thank you.  Just curious, what does this checking?

$vm.ExtensionData.UpdateViewData('Guest')

0 Kudos
LucD
Leadership
Leadership
Jump to solution

The vSphere objects (returned by Get-View or via the ExtensionData property) are not refreshed automatically.

With the UpdateViewData method call you can ask for the refresh of such an object, or of a property in such an object.


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

0 Kudos
dwchan
Enthusiast
Enthusiast
Jump to solution

That's right, I see that behavior.  Thank you again

0 Kudos