Powershell script to monitor mount points in Windows and e-mail an alert

Simple script inspired by this blog post.

This script will read a servers.txt file located in the same directory as the script, check each server listed (one per line, use the servers FQDN) for mount points, see how much free space is available, compare it to a minimum amount you set and then e-mail an alert if below the minimum amount.

Should work on Windows Server 2008 and newer. Might work on Server 2003 but I haven’t tested it.


7 thoughts on “Powershell script to monitor mount points in Windows and e-mail an alert

    • I would suspect because either the ‘To’ address isn’t set correctly, your SMTP server isn’t set correctly or the server that runs the script doesn’t have access to relay e-mail via your configured SMTP server.

  1. hello, how can I make it work with %. say for example, I like to get warning if it below 10%. thank you.

    Golam Kabir

  2. Hi Eric,

    How to use this if one likes to make the lowspace on %. For example, i like to get noticed if the volume space is lower than 10%. Thank you

    • You could modify the script to do some math for you (current size divided by max size) to get the percentage and then change the ‘if’ statement to look at that percentage instead of the hard limit I have.

      We prefer absolutes instead of percentages so that’s why I wrote the script this way.

  3. Eric,


    in my environment some volumes like cluster resource are so small that an absolute value make no sense. therefore, i’ve been thinking about going %. I’ve tried the following


    # Do some math to convert bytes into GB, rounded and 2 decimal places
    if (([math]::round(($volume.FreeSpace / volume.size) * 100,2)) -le $lowSpace).

    this give me no email. could you please guide me . thank you.

    • The first thing to find out is whether or not the issue is your script is or isn’t triggering properly. Set the minimum number to something that will trigger no matter what. If you don’t get an e-mail then the issue is the mail settings. Did you configure your SMTP properly? and is it allowing you to relay from the server you are running the script on?

      If SMTP isn’t the issue then it’s the trigger condition. I can’t help you much there since you’re changing the script. I’d recommend hitting up stackexchange.com

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.