Hi All,
I wrote a script to monitor Free disk space if any of the drives gets to say 20GB on a server with multiple disks, but the issue is it sends the email for each drive...
is there a better way to make all results go out in a single email, rather than multiple.
Here is a sample of the script:
' List Available Disk Space
Const HARD_DISK = 3
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk Where DriveType = " & HARD_DISK & "")
If CInt(objDisk.FreeSpace/1024/1024/1024) < 20 Then
For Each objDisk in colDisks
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "helpdesk@fusionsystems.co.jp"
objEmail.To = "pius.oshinuga@fusionsystems.co.jp"
objEmail.Subject = "RED ALERT: DISK SPACE RUNNING LOW!!"
objEmail.TextBody = "Drive: "& vbTab & objDisk.DeviceID & vbTab & "Free Space: "& vbTab & CInt(objDisk.Size/1024/1024/1024) & "GB" & vbTab & "Total Size: "& vbTab & CInt(objDisk.FreeSpace/1024/1024/1024) & "GB"
objEmail.Configuration.Fields.Item _
(" = 2
objEmail.Configuration.Fields.Item _
(" = "tok-exch"
objEmail.Configuration.Fields.Item _
(" = 25
objEmail.Configuration.Fields.Update
objEmail.Send
'Wscript.Echo "Drive: "& vbTab & objDisk.DeviceID & vbTab & "Free Space: "& vbTab & CInt(objDisk.FreeSpace/1024/1024/1024) & "GB" & vbTab & "Total Size: "& vbTab & CInt(objDisk.Size/1024/1024/1024) & "GB"
Next
End If
Thank you for your assistance
I wrote a script to monitor Free disk space if any of the drives gets to say 20GB on a server with multiple disks, but the issue is it sends the email for each drive...
is there a better way to make all results go out in a single email, rather than multiple.
Here is a sample of the script:
' List Available Disk Space
Const HARD_DISK = 3
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk Where DriveType = " & HARD_DISK & "")
If CInt(objDisk.FreeSpace/1024/1024/1024) < 20 Then
For Each objDisk in colDisks
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "helpdesk@fusionsystems.co.jp"
objEmail.To = "pius.oshinuga@fusionsystems.co.jp"
objEmail.Subject = "RED ALERT: DISK SPACE RUNNING LOW!!"
objEmail.TextBody = "Drive: "& vbTab & objDisk.DeviceID & vbTab & "Free Space: "& vbTab & CInt(objDisk.Size/1024/1024/1024) & "GB" & vbTab & "Total Size: "& vbTab & CInt(objDisk.FreeSpace/1024/1024/1024) & "GB"
objEmail.Configuration.Fields.Item _
(" = 2
objEmail.Configuration.Fields.Item _
(" = "tok-exch"
objEmail.Configuration.Fields.Item _
(" = 25
objEmail.Configuration.Fields.Update
objEmail.Send
'Wscript.Echo "Drive: "& vbTab & objDisk.DeviceID & vbTab & "Free Space: "& vbTab & CInt(objDisk.FreeSpace/1024/1024/1024) & "GB" & vbTab & "Total Size: "& vbTab & CInt(objDisk.Size/1024/1024/1024) & "GB"
Next
End If
Thank you for your assistance