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,538 times
Add to favorites
Storage
8/12/2011
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Unable to process script without error
    2 Posts | Last post February 11, 2019
    • Sorry, I'm completely new to PowerShell and scripting.
      
      I've copied the script and amended it where necessary, for instance the report / output folder / files, but I keep getting the following error when running in;
      
      Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
      At E:\PowerShell Scripts\CDSP.ps1:132 char:11
      +     $disks = Get-WmiObject -ComputerName $computer -Class Win32_LogicalDisk -Filter ...
      +    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMException
          + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
      
      In the servers_c.txt file I have 3 servers in there;
      IP-Address
      NAME
      IP-ADDRESS
      
      So I'm not entirely sure what formatting I should use in this file.
      So any help would be greatly appreciated, thanks.
    • Apologises, I don't know how to edit my post above. However the error I'm getting, is when I'm trying to run this script on the server and I'm trying to obtain the disk space information from it.
      In the servers_c.txt I have one line with the IP-ADDRESS and then next with the Computer-Name.
      
      If I just have the IP Address in the .txt, then I get nothing in the HTML file, other than the headings etc.
      
      If I run the get-wmiobject command to get the disk space, I get the following;
      
      PS E:\PowerShell Scripts> get-wmiobject -computername eng-ipid -class win32_logicaldisk -filter "drivetype = 3"
      
      
      DeviceID     : C:
      DriveType    : 3
      ProviderName :
      FreeSpace    : 22859948032
      Size         : 42580570112
      VolumeName   :
      
      DeviceID     : E:
      DriveType    : 3
      ProviderName :
      FreeSpace    : 155951329280
      Size         : 171795542016
      VolumeName   : New Volume
  • 1 server showing NaN
    1 Posts | Last post October 31, 2018
    • Please disregard last post... threshold is working perfectly!
      
      Only problem now is 1 server is showing "NaN".  I cannot get drive details.
      This server is setup exactly as the other servers.
      
      Please advise?
  • Few issues with script I can't fix
    1 Posts | Last post October 31, 2018
    • 1- I 6 server names listed in text file.  Each server has two drives (C & D).
      After script runs, only two servers show fine.
      One server only the "C" drive shows (D drive is missing).
      One server only shows "NaN".
      Two servers do not show at all.
      
      2- Threshold is being ignored no matter what I set it to.
      Email is always sent regardless if below the threshold or not.
      # Set your warning and critical thresholds 
      $percentWarning = 15; 
      $percentCritical = 10; 
       
  • Missing few logical drives data
    1 Posts | Last post February 22, 2018
    • When I running the script with multiple servers. It is not displaying data in all the drives. Few drives data it is missing. Could you please let me know , what to do now!
  • How to exclude C:\ drive from this report?
    1 Posts | Last post December 12, 2017
    • How to exclude C:\ drive from this report?
      
      I have tried below filter, C:\ drive space info not updating  but getting row with NAN 
      
      please help me on this ...
      Server	Drive	Drive Label	Total Capacity(GB)	Used Capacity(GB)	Free Space(GB)	Freespace %
      A	F:	TempDB	5	4.03	0.97	19.34
      A			0	0	0	NaN
      B	T:	VMWare Update Manager	20	14.64	5.36	26.81
      B			0	0	0	NaN
      C	E:	DB DATA	600	521.02	78.98	13.16
      C			0	0	0	NaN
      
      Thanks,
      Ram
      
      
  • TB and e-mail
    1 Posts | Last post November 03, 2017
    • Hi everyone,
      
      I have two doubts.
      
      1. As Jacob mentioned I want to expand as TB also.
      2. When I try run the script in the end a received the erro:
      
      Sending Email notification to it@mega.edu.au
      Exception calling "Send" with "1" argument(s): "The SMTP server requires a secure connection or the client was not 
      authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. u6sm9352282pfg.175 - gsmtp"
      At C:\xxxxxxxxxxxxx\CheckDiskSpace_post.ps1:202 char:3
      +         $smtp.Send($msg)
      +         ~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
          + FullyQualifiedErrorId : SmtpException
      
      I need to setup the smtServer as "smtp.gmail.com"
      
                      $smtpServer = "smtp.gmail.com"
      		$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
      		$msg = New-Object Net.Mail.MailMessage
      		$msg.To.Add($user)
              $msg.From = "xx@xxxxx.xxx.xx"
      		$msg.Subject = "Environment DiskSpace Report for $titledate"
              $msg.IsBodyHTML = $true
              $msg.Body = get-content $diskReport
      		$smtp.Send($msg)
              $body = ""
      
      Thank you
  • TB
    1 Posts | Last post May 26, 2017
    • I see that alot of these types of scripts go up to GB
      is there anyway to expand it to TB also?
      Thank you
  • Get WmiObject error
    1 Posts | Last post April 10, 2017
    • Hi All,
      
      I am receiving the following error when running the script...
      Get-WmiObject : Invalid query "select * from Win32_LogicalDisk where DriveType = 3"
      At line:132 char:11
      +  $disks = Get-WmiObject -ComputerName $computer -Class Win32_LogicalDisk -Filter ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidArgument: (:) [Get-WmiObject], ManagementException
          + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
       
      Get-WmiObject : Out of memory 
      At line:132 char:11
      +  $disks = Get-WmiObject -ComputerName $computer -Class Win32_LogicalDisk -Filter ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], ManagementException
          + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
       
      IW-W0200 C: percentage free space = 9.13
      
      -------------
      Then script just stays on 'running' until I manually stop the script.
      
      Computer objects in the file is around 360 - (I know this script was intended for servers however I'm using it to query workstations)
      The text file of machines is generated from;
      
      $IWLaptops = Get-ADComputer -Server "*****.******.net"  -SearchBase "OU=Laptops,OU=Clients,OU=*******,DC=********,DC=net" -Filter {(enabled -eq $True)} | Where-Object {$_.name -like '*iw*'}  | Select name
      foreach ($IWlaptop in $IWLaptops) 
      {
      If (Test-Connection $IWLaptop.name -count 1 -quiet) 
      {$laptopssonline += $IWLaptop.name }
      }
      $laptopsonline| Out-File c:\Scripts\clients.txt
      
      I have tried increasing thr memory - http://jeffwouters.nl/index.php/2014/03/out-of-memory-exception-in-powershell/
      But still no luck. Anyone any ideas?
      Thanks in advance.
  • Page Drive
    4 Posts | Last post February 02, 2017
    • This script is working great.  I want to exclude the page drive.  any ideas?
    • I figured it out.  This was the easiest way to omit the page drive.
      
      foreach($disk in $disks | where {$_ -notmatch "P:"})
    • thanks, that data was looking
    • Hi Friend, 
      
      Can I get the updated script. Could you please share me in rakeshnv@outlook.com
  • MountPoints added?
    1 Posts | Last post February 01, 2017
    • This script runs great. I have it on a scheduled task to run twice a day. However, I would love for it to include mount points as well. Is there a way to do this in one script? It would also be great if the emailed information would state if it is unable to run on a particular server. My script errors out on a few in the servers.txt file but I'm not sure which ones and can only see it if I am watching the script run. 
1 - 10 of 39 Items