Track Datastore Free Space

I’ve got a great new script for you today!

We all love VMware for consolidating our servers. And we all know that virtualization requires lot’s of SAN space. But how do you keep track of the amount of space left on all your datastores? It’s pretty easy to create a report using the Powershell VI Toolkit. But who is going to read all those reports and compare them to yesterday’s values? You will most likely end up with a mailbox full of reports and still be surprized when yet another datastore fills up.

PeetersOnline to the rescue! How about storing the report every day and comparing today’s values to yesterday’s values? Then you can email yourself only the differences. The overview shows the datastores that changed since yesterday, the change rate and the current value. This way, you can easily assess if the datastore is about to fill up.

Because it is quite a large script (in Powershell terms) and it contains long lines that are not easily readable on my site, I have attached the script for you to download. It contains lot’s of comments, so you should be able to follow exactly what it does and how it works. If not, post a comment.


Track-Datastores (Rename to .ps1)

11 thoughts on “Track Datastore Free Space

  1. Hello Guys,

    very nice script!

    How can i add commands for sending me an alert if datastore capacity is for an example below 10% of complete storage?

    Thanks in advance.


  2. […] Link | Add Custom Fields to VI Client with Powershell Link | VMware Health Check Script Link | Track Datastore Free Space Link | List disk RDMS Link | Find Snapshots and Send email to User Link | Setting Video Hardware […]

  3. hello Hugo 🙂

    many tnx for your help (how do manipule variable)

    pls, i have an under gestion.
    can i creat an exe file from the PS script file ?


  4. # Export the output to an xml file; the new Current file
    $myColCurrent | Export-csv -Path “$Folder\$currentFile”

    # Disconnect from Virtual Center
    Disconnect-VIServer -Confirm:$False

    # Finally, let’s compare the Current information to that in the Previous file

    # Check if a Previous file exists
    If (Test-Path “$Folder\$previousFile”)
    # Import the Previous file
    $myColPrevious = Import-Csv “$Folder\$previousFile”

Leave a Reply