Taking screenshots of VM consoles

A client of mine asked for assistance in identifying virtual appliances in their environment, in order to tag them for future work they had planned.

As they had many thousands of VM’s, it would have been an arduous task to review them one-by-one. As the vast majority of virtual appliances are not windows based, I was able to narrow the field down to a few hundred VM’s that needed a manual review.

The question then became; how to distinguish a virtual appliance from a normal *nix-based VM? The easiest way would be to look at the console of each VM!

Rather than re-invent the wheel, I looked around for any PowerCLI scripts that would take a screenshot of a VM console and found one written by
Patrick Terlisten
.

While Patrick’s script did the job for a few VM’s, I needed to be able to hit hundreds of VM’s across a number of different clusters as well as wake the consoles up so the screenshot wasn’t just a black screen.

After tweaking the code, and a little help from William Lam’s blog, I was able to come up with my own version of the script that had the functionality I required.

You can view my script on GitLab here: https://gitlab.com/KarmicIT/public/blob/master/Get-ScreenshotFromVM.ps1

You should now have suitable .png files saved to a sub-folder called “screenshots\vcenter-name” in your workingdir. If you specified a cluster or datacenter name, these would have been created as folders as well.

NOTE: Remember I was only after non-Windows VM’s, so if you would like to use this for all VM’s you will need to remove or edit the following portion of code;

Leave a Reply

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

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.