We did two live demos as part of VI Toolkit’s breakout session at VMworld Europe 2009. A while ago, I made a post about the network monitoring demo. As LucD politely reminded me : ) it’s time to finish the job with a post on the second demo. In it, PowerShell scripts were sending mouse and button clicks to a virtual machine’s guest OS to automate installer which otherwise does not support unattended installation…
Every once in a while I find myself in a situation where I can save tons of work with a very simple UI automation. In this specific case, I’m upgrading the VMware Tools on my VMs. The Update-Tools cmdlet is the right tool for the job. There’s a small problem in my case though…
The new version of VMware Tools I’m installing is still a beta and hasn’t passed Microsoft’s driver quality tests. So when Update-Tools runs the installer, Windows pops “unsigned driver” confirmation dialog and blocks the installation. In result, Update-Tools blocks on the first VM. That’s where UI automation comes into play. I need a script which goes inside the VM’s guest OS and clicks on the confirmation button.
Windows Automation Snapin for PowerShell (or WASP) is a set of cmdlets for UI interaction. UI interaction includes stuff like finding windows and controls and sending them mouse clicks, keyboard input, etc. Sounds like the right tool for my task. I’ll need to run it not on my machine but inside each individual VM. VI Toolkit’s cmdlet for in-guest execution is Invoke-VMScript.
Finally, below is the script. Two notes:
– You need to be connected before you run it.
– For simplicity’s sake (this was a VMworld demo), the script only operates on a single machine. Extending it to work on a set of VMs is pretty straightforward.
Note: In a real life scenario, you may need to include a step for installing WASP. This includes copying WASP to the VM and invoking WASP’s Instal.ps1 script.