none
Check disk space with powershell

    Question

  • Hi all,

    I've just write a script in powershell to check the free space on all the volumes from a server list. I can work in GB or in %. The problem is that not all the volumes have the same amount of total space. Some can have 5Gb and others can have 2TB. So working with GB or % for the alert is not adequate. 

    Can I with powershell use a function like logarithm to achieve this? So the alert of free space will be different depending of how bigger is the volume.

    Regards,

    • Moved by Bill_Stewart Friday, July 04, 2014 1:06 AM Question outside forum scope
    Saturday, February 15, 2014 4:40 PM

All replies

  • I have a few scripts in the gallery that are made for this scenario:

    http://gallery.technet.microsoft.com/Server-HDD-Space-6d8d6805

    or 

    http://gallery.technet.microsoft.com/Rapid-Hardware-Query-269d1a3a


    - Chris Ream -

    **Remember, if you find a post that is helpful, or is the answer, please mark it appropriately.**

    Saturday, February 15, 2014 7:04 PM
  • Yours scripts return the free space etc...I've done this part too. What I'm looking for is a way to alert me via email when the disks or volumes are under a certain threshold. But I can't use the same threshold for a 5GB volume and a 1TB volume...so instead of doing a plenty of if statements, I'm looking for a formula that will be based on the volume size to determine the threshold, something like a Logarithm ex. log(x,y)

    Thanks

    Saturday, February 15, 2014 9:09 PM
  • So you want something like a scheduled task that will check your disk space and email you when a threshold is met?

    You can make that a scheduled task from one server or from each server.  Which would you prefer?


    - Chris Ream -

    **Remember, if you find a post that is helpful, or is the answer, please mark it appropriately.**

    Saturday, February 15, 2014 9:20 PM
  • Yeah,

    No problem with the email and with the schedule task. 

    The only this is that I can't set a common threshold because if I put 10% of threshold, a 1TB volume will warn at 100Gb, that is not an emergency..

    If I put 1%, a 5GB volume will warn at 50MB, that is not good...so I'm looking for a formula that will take in consideration the volume size to determine the threshold...and I don't want to handle the threshold server by server....

    Following me?

    Saturday, February 15, 2014 9:24 PM
  • I would use a static size then.  When 1GB is available, then send email to someone saying 'I am at % free. 1GB of <some size> available. Come help me'

    That eliminates the problem with the percentage.  Pick a common remainder.

    I have always found this to be the problem with SCOM.  It sends me a threshold warning but I don't know what that threshold is.  That's why I wrote the DriveSpace Query I sent you the link to.  So when I get the emails, I can just get a quick snapshot on what that warning really means.


    - Chris Ream -

    **Remember, if you find a post that is helpful, or is the answer, please mark it appropriately.**


    Saturday, February 15, 2014 9:32 PM
  • We call this a self-negating question.  No matter which answer is chosen it becomes one of the unacceptable answers.

    What does a log have to do with knowing how much free space there is.  Percent is the closest you will get or use percent except when volume is less than some size.

    In any case all of this is kind of senseless because space needs to be trended.  We have reports that show a graph of history.  THe graphmakes it possible to detect rate of use (or rate of filling up) visually.


    ¯\_(ツ)_/¯

    Saturday, February 15, 2014 10:27 PM
  • This not a self-negative question. Just need to find the right formula that fit the needs. 

    Sunday, February 16, 2014 1:52 AM
  • To get the right answer you have to ask the right question.

    What is it that you need to know.  Don' talk formulas and code just state in plain English what it is you need. 


    ¯\_(ツ)_/¯

    Sunday, February 16, 2014 1:58 AM
  • What I need is a way to bring an alert when a volume is getting near a certain limit. The alert part is an email and working.

    What I' trying to explain is that a volume with 1TB of space don't need to trigger the alert at the same % of a volume of 5GB...but I don't want to manage a bunch of threshold because I need to monitor hundreds of volumes of differents size. 

    So logically I'm wondering how can I achieve this...

    Sunday, February 16, 2014 2:21 AM
  • What I need is a way to bring an alert when a volume is getting near a certain limit. The alert part is an email and working.

    What I' trying to explain is that a volume with 1TB of space don't need to trigger the alert at the same % of a volume of 5GB...but I don't want to manage a bunch of threshold because I need to monitor hundreds of volumes of differents size. 

    So logically I'm wondering how can I achieve this...

    Apparently you haven't learned.  There is a builtin utility that does exactly that.  You just have to configure it.  It can be configured through Group Policy.  It has been part of Windows NT since day one.  I suspect your Domain Admins or the vendor that set up you domain may have already set it up.  It is installed and enabled by default in Windows Small Business Server.


    ¯\_(ツ)_/¯

    Sunday, February 16, 2014 2:39 AM
  • See the following tools:

    Steps for viewing a diagnosis report

    To view the System Diagnostics report

    1. Start Windows Performance Monitor.In the navigation tree, expand Data Collector Sets and expand System.

    2. Right-click System Diagnostics and click Start. Data Collection will begin.

    3. In the navigation tree, expand Reports, expand System, expand System Diagnostics, and click the current date.

    4. When data collection and report generation are complete, the System Diagnostics report will appear in the console pane.

      noteNote
      This report collects data for 60 seconds. It may take up to an additional 60 seconds for the report to be generated.

    http://technet.microsoft.com/en-us/library/dd744567(v=ws.10).aspx


    ¯\_(ツ)_/¯

    Sunday, February 16, 2014 2:47 AM
  • Here is the Windows 7/8 builtin report templates.

    http://1drv.ms/1g8eXq1



    ¯\_(ツ)_/¯


    • Edited by jrv Sunday, February 16, 2014 3:13 AM
    Sunday, February 16, 2014 3:07 AM