Tablets How to monitor Free Hard Disk Space with VBScript | BLOG IT

How to monitor Free Hard Disk Space with VBScript

This is a useful script which helps to monitoring hard disk frees pace on Windows Servers, you can use it in order to know if one of your servers is running out of space, you could configure it with a
Schedule Task.

This script works and sends an email messages when free disk space is below of 10% from total hard disk space, you could customize it as your convenience.

Dim objFSO, space1, space1gb, message
Set objFSO = CreateObject ("Scripting.FileSystemObject")

For each objdrive in objFSO.Drives

'objdrive.drivetype = 2 ---This is the Local Drive, it means, no DVD, no Diskette, only Hard Drives.
If objdrive.drivetype = 2 then
'space1 On this variable we store the 10% of free space for total hard disk
space1 = ((objdrive.totalsize)*0.9)
'space1gb  On this variable we transform space to Gigabytes (GB).
space1gb = ((objdrive.freespace / 1000000000))
'wshNetwork with this variable we get server name
Set wshNetwork = WScript.CreateObject( "WScript.Network" )
strComputerName = wshNetwork.ComputerName

If objdrive.freespace < space1 Then
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Low Space on Disk " &objdrive.Driveletter &":" &" For Server: " &strComputerName
objMessage.From = ""
objMessage.To = ""
objMessage.To = ""
objMessage.TextBody = "On Server " &strComputerName &" Only remains: " &space1gb &" GB" &" On Disk: " &objdrive.Driveletter

'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("") = ""

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("") = 25


'==End remote SMTP server configuration section==

end if

end if

set objFSO  = nothing
set wshNetwork = nothing


About Robert SA

    Blogger Comment
    Facebook Comment

0 comentarios: