VI Toolkit Demos at VMworld Europe 2009 (Part 2 of 2: UI Automation)

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.


2 comments have been added so far

  1. Thanks Andrey. Great sript!
    It was the “Select-Control -Window 0” that I didn’t remember from the session.
    Any pointers how you found this out ?

  2. The driver confirmation window proved very hard to locate indeed. The reason is its odd placement in the window hierarchy – its top level parent is hidden.
    Jaykul (WASP’s author) helped me with locating it. My guess was that I should use Select-Window which is probably what you tried. This works with the vast majority of windows but not with this one.
    Last thing I know, Jaykul was considering enhancement to Select-Window so it can cover this case. I wouldn’t be surprised if it works in WASP’s latest version.

Leave a Reply

Your email address will not be published. Required fields are marked *