Disk Space Report - Reports only disks that are below a threshold - HTML output.

I have created a Powershell script to report on a list of server's disks space.  Unlike most reports out there, this one only reports on those disks that are below the set thresholds.  My previous attempt at this saved the results to a CSV file, attached to an email and sent out

 
 
 
 
 
4.7 Star
(13)
14,969 times
Add to favorites
Storage
8/12/2011
E-mail Twitter del.icio.us Digg Facebook
  • Doesnt Pickup Server List
    1 Posts | Last post September 27, 2013
    • Hey ... I'm stuck.   I've read through all the comments and tried everything suggested.   The script comes back empty with the NaN in the FreeSpace column.   I am just running this locally from Powershell prompt, no Task involved.  I've set the path for the servers.txt, I've used IP address, FQDN ... nothing.   I get no output.
       
  • I get a error at the button
    1 Posts | Last post July 26, 2013
    • Exeption calling "Send" with "1" argument(s): "Failure sending mail."
      at c:\output\diskspacereport.ps1:203 char:13
       + $smtp.Send <<<< <$smg>
      + CategoryInfo : NotSecified: (:) [], MEthodInvocationExeption
      + FullyQualifiedErrorID : DotNetMethodExceptopm
  • When Running As A Scheduled Task Doesn't Work Correctly
    2 Posts | Last post April 04, 2013
    • When the script is setup to run as a Scheduled Task on a Server 2008R2, it returns all columns empty, except the Freespace % column as NaN and in red. I don't see NaN in the code anywhere.
      
      The script executes fine when run directly from the ps1 or when running from a batch that points to powershell.exe C:\CheckDiskSpace_post.ps1
      
      What are the correct settings to have this run as a scheduled task on an hourly interval.  Thank you!
    • I found that to get the Task to run I need to place the location of files in the start in location for the Task.
  • Error
    1 Posts | Last post February 19, 2013
    • Hey Mike,
      Rookie to scripting, testing your script and got it to work great but after the last server on the list it comes up with error and repeats the disk space like 3 times 
      
      EXSNGBRK2 C: percentage free space = 57.76
      Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argument is null or empty. Supply an
      argument that is not null or empty and then try the command again.
      At line:3 char:38
      + $disks = Get-WmiObject -ComputerName $computer -Class Win32_LogicalDisk -Filter  ...
      +                                      ~~~~~~~~~
          + CategoryInfo          : InvalidData: (:) [Get-WmiObject], ParameterBindingValidationException
          + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.GetWmiObjectCommand
      
       C: percentage free space = 57.76
      Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argument is null or empty. Supply an
      argument that is not null or empty and then try the command again.
      At line:3 char:38
      + $disks = Get-WmiObject -ComputerName $computer -Class Win32_LogicalDisk -Filter  ...
      +                                      ~~~~~~~~~
          + CategoryInfo          : InvalidData: (:) [Get-WmiObject], ParameterBindingValidationException
          + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.GetWmiObjectCommand
      
       C: percentage free space = 57.76
      Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argument is null or empty. Supply an
      argument that is not null or empty and then try the command again.
      At line:3 char:38
      + $disks = Get-WmiObject -ComputerName $computer -Class Win32_LogicalDisk -Filter  ...
      +                                      ~~~~~~~~~
          + CategoryInfo          : InvalidData: (:) [Get-WmiObject], ParameterBindingValidationException
          + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.GetWmiObjectCommand
      
      any help would be appreciated
      Thanks
  • Show C Drive Only in report
    1 Posts | Last post November 12, 2012
    • Hi,  I am a rookie at scripting, I have ran this script and it is great but I only need report for the C Drive on all my servers, How could I change this script to only display C Drive in the report?
      
      Thanks In Advance
  • can't show all of the logical drivers
    1 Posts | Last post October 27, 2012
    • Hello,
      thanks for this great script.
      but I tested on several servers, most of them can't be shown all of their logical drivers from this script.
      
      But if I just use:
      Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType = 3"
      from powershell, it shows all of the logical drivers.
      
      In plus, some of the commands in this script seem to be not compatible with windows server 2011 SBS.
      
      Thank you again
      
  • Unable to send mail
    1 Posts | Last post September 17, 2012
    • Hi there..
      I'm getting following error while sending mail:
      Exception calling "Send" with "1" argument(s): "Failure sending mail."
      At F:\OSR\ToolDev\DiskCleanupNewDev\DeleteOldFiles_Notification.ps1:44 char:13
      +   $smtp.Send <<<< ($msg)
          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
          + FullyQualifiedErrorId : DotNetMethodException
      
      My e-mail sending script is something like this. Am I missing anything here?
      
        Write-Host "Sending Email notification to $user" 
        $smtpServer = "smtprelay.xxxx.com:25" 
        $smtp = New-Object Net.Mail.SmtpClient($smtpServer) 
        $cred = New-Object System.Net.NetworkCredential
        $cred.Domain = "xxxxx"
        $cred.Username = "xxxx"
        $cred.Password = "xxxx"
        $smtp.Credentials=$cred
        $msg = New-Object Net.Mail.MailMessage 
        $msg.From = "myfirstname.mylastname@mycompany.com" 
        $msg.To.Add("myfirstname.mylastname@mycompany.com")
        $msg.Body = "1"
        $smtp.Send($msg) 
      
      Please help?
  • How does this get trigger....
    6 Posts | Last post September 21, 2011
    • Nice report  Mike. how  can  we run this  so  it  will get  trigger at the space level.
    • Can you explain further what you are asking?
    • Hi Mike,
      I have run the Script on a Windows 2008 Server, but the HTML file is created ,but the report is Blank.
      
      Regards
      Balaji
    • GSenanayake,
      
      The only way that I am aware of doing that is in Windows Server 2008 R2/Windows 7.  You have to set a trigger using scheduled tasks that detects when the disk space is low and then runs the report.
      
      -Rich
    • Balaji, you will most likely need to modify the following line to a folder that exists.    $reportPath = "D:\Jobs\DiskSpaceQuery\Reports\";
    • Balaji, 
      The code is on the page has a smallest error. Mike forgot a } in the "# Set background color to Orange if just a warning 
       if($percentFree -lt $percentWarning)       
        { 
          $color = $orangeColor  #####Here##### put a }
      
      This script is marvelous. Thanks, Mike!
  • modify script to get physical disk
    1 Posts | Last post September 15, 2011
    • Hello all,  I found this power shell script which works perfectly fine....here is the script...But how can i modify the script so this works on a clustered server....reason being....lets say i have a drive letter I:  But it only shows up about 1GB totaly capicity and used it 0.35G but when i go inside I drive it has more folder saying as data logs and they are mounted on a different disk....which dose not show up in the report ??? if you know what i mean...how can i over come this ??  looks like the I drive is logical and once we go inside I drive ...the data, logs folder is mounted on a different disk...which might be physical....
31 - 39 of 39 Items