PowerCLI Script to Download VM Screenshots from Datastore

Occasionally, you may need to download virtual machine files from the Datastore. For example, If vSphere HA resets virtual machines, there is a good chance just before it reset it, vSphere HA VM monitoring took a screenshot of the VM console, storing it with the VM configuration files on the Datastore.

Reset by vSphere HA. Reason: VMware Tools heartbeat failure. A screenshot is saved

Downloading these files is done simply by browsing the datastore VM directory via the UI and selecting the file or files to download. These days I find this can be tedious with the size of clusters, and with vSAN’s directory structure, you could be sifting through hundreds or even thousands of directories.

I decided to write a quick little Powershell script to quickly and automatically download these files, and you can even use this script to download other files like vmware.log files. I have tested this script on vSphere 6.7U3 with vSAN and VMFS6 Datastores.

You can download the script here vm-file-downloader.ps1 or copy the code below.

I hope you found this useful, if you have any feedback feel free to contact me. 🙂

Leave a Reply