Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
locComputer = "."
'set the WMI service & shell
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& locComputer & "\root\cimv2")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
server = WshNetwork.ComputerName
'Only report drives with less than this percent free
LowSpaceThreshold = 0.15
'Only check drives bigger than this amount (in GB)
MinimumDiskSizeToCheck = 5
'Send email to this address
emailAddress = "user@company.com"
'SMTP server
smtpServer = 192.168.100.100
arrVolume = Array("ServerName/Volume1")
'Run script below for every entry in array
For Each strVolume In arrVolume
Set colDisks = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk")
LowSpaceFound = 0
For Each objDisk in colDisks
'Change from Bytes to GB
DiskSize=objDisk.Size/(1024*1024*1024)
DiskFree=objDisk.FreeSpace/(1024*1024*1024)
If DiskSize > MinimumDiskSize Then
If Not IsNull(DiskSize) Then
DiskSize = Round(DiskSize, 1)
End If
If Not IsNull(DiskFree) Then
DiskFree = Round(DiskFree, 1)
End If
PercentFree = Round (DiskFree/DiskSize, 2)
If PercentFree < LowSpaceThreshold Then
LowSpaceFound = 1
strText= strText & objDisk.DeviceID & " "& PercentFree*100 & "% Free" & vbCrLf & " Total: " & DiskSize & " GB " & vbCrLf & " Free: " & DiskFree & " GB " & vbCrLf & vbCrLf
End If
End If
Next
Next
strText = strText & vbCrLf & "This report excludes drives whose Total Size is less than " & MinimumDiskSizeToCheck & "GB (CD/DVD Drives). It is scheduled to run on " & server & ". Check Control Panel-->Scheduled Tasks to delete or modify this job."
If LowSpaceFound > 0 Then
Set objEmail = CreateObject("CDO.Message")
objEmail.From = server & "_Free_Space_Notifier"
objEmail.To = emailAddress
objEmail.Subject = server & " - Drives with free space < " & LowSpaceThreshold * 100 & "%"
objEmail.Textbody = strText
objEmail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
objEmail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = _
smtpServer
objEmail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25
objEmail.Configuration.Fields.Update
objEmail.Send
End If