Monitoring VMWare with PowerShell


Use PowerShell to monitor guest disk usage and generate automated reports.

My first leader in Information Technology (IT) believed in building processes for recurring or bulk tasks. You could perform repetitive tasks and be less efficient, he would not force you to do otherwise, but it was easy to see why he valued the expenditure of a little more time and energy upfront in order to save time and energy later (over and over again!). This led our team to write code that solved various problems and made us more efficient. Today, we use the term DevOps, which Wikipedia says “is a set of practices that combines software development (Dev) and IT operations (Ops)”.


A classic IT issue is a system crashing due to filling a disk drive until the system can no longer function. This is as true in a virtual environment as it is with physical systems. In a virtual environment such as VMWare, using ESXi hosts with or without a VMWare vCenter Server, an administrator has a very easy means to extend the size of virtual machine hard disks or add additional disks. The monitoring of disk usage in an efficient manner typically requires paying for additional products. Years ago, when confronted with this problem, and imbued with the DevOps spirit, I taught myself enough PowerShell to utilize VMWare’s PowerCLI module in order to both monitor and alert on virtual machine disk space issues. The following video shows you how to take my sample script and monitor disk usage in your own environment in under two minutes.

Once I completed the initial script, I scheduled it to run as a Scheduled Task in Windows to send regular reports. I wrote an additional script that ran daily and sent an alert email only when disks had less than 10% free space. This proved to be immensely valuable and allowed us to be proactive about storage issues, prompt us to research root causes, and save us an immense amount of time.

In the years that followed those first two scripts, I leveraged PowerShell for more and more. PowerShell continued to mature, as did VMWare’s PowerCLI module. These days, you can write portable PowerShell that is usable on Windows, Linux, and macOS.

The following sample VMWare environment report was automatically generated in my lab by a PowerShell script, one that was developed entirely on a Mac.

As you can see from the sample report, there is an immense amount of value in writing custom code to report on your critical IT systems. Doing so can greatly reduce your risk by greatly reducing the potential for downtime. Taking this further, you can write code to self-heal issues without intervention, assist in reading and writing configuration, and so on.


If your organization can benefit from more DevOps thinking, or if you would like to have your VMWare environment evaluated with our custom code, contact us today.

Was this helpful?