Don't have the answer but here is some related script that may point you in the right direction.
Author: Jason Tanem
Description:
This script reads in the names of drives and sends an email warning via Outlook if finds that a drive is below 2.5 GB free.
Script:
'= This script reads in the names of drives =
'= <vDriveList> and sends an email warning via =
'= Outlook if finds that a drive is below 2.5 GB =
'= of free space. =
'= =
'= The text file <vDriveLlist> format should contain =
'= one drive entry per line as follows: =
'= =
'= C =
'= D =
'= \\server\resource name =
'==============
'Written by Jason Tanem
'------------Declarations-------
dim vFileSys, vShell, vLowIndicator, vDrv
dim vDrvFree, vOutlook, vMessage, vMailTo
dim vDriveList, vOpenText, vTextLine
vDriveList = "C:\Temp\Shares.txt"
'-------------Functions------
'Boolean for space above or below 2.5 GB
Function FreeSpaceStatus(drvPath)
set vFileSys = CreateObject("Scripting.FileSystemObject")
set vDrv = vFileSys.GetDrive(drvPath)
vLowIndicator = "OK"
If FormatNumber(((vDrv.FreeSpace/1024)/1024)/1024, 0) < 2.5 Then
vLowIndicator = "Low"
End If
FreeSpaceStatus = vLowIndicator
End Function
'This function returns drive free space in GB
'-----------
Function FreeSpace(drvPath)
Set vFileSYs = CreateObject("Scripting.FileSystemObject")
Set vDrv = vFileSys.GetDrive(drvPath)
vDrvFree = FormatNumber(((vDrv.FreeSpace/1024)/1024)/1024, 2) & " GB"
FreeSpace = vDrvFree
End Function
'------------Main------
Set vFileSys = CreateObject("Scripting.FileSystemObject")
Set vOpenText = vFileSys.OpenTextFile(vDriveList)
Do While vOpenText.AtEndOfStream <> True
vTextLine = vOpenText.ReadLine
If FreeSpaceStatus(vTextLine) = "Low" Then
'Create and send the email by calling on Outlook via COM
'----------------
Set vOutlook = CreateObject("Outlook.Application")
Set vMessage = vOutlook.CreateItem(0)
With vMessage
Set vMailTo = vMessage.Recipients.Add("jptanem@mapllc.com")
vMailTo.Type = 1
.Subject = "Low drive space on network resource"
.Body = vTextLine & " is down to " & FreeSpace(vTextLine)
.Importance = 2
.Send
End With
End If
Loop
'Clean Up
'---
set vFileSys = Nothing
Set vShell = Nothing
Set vOpenText = Nothing
Set vOutlook = Nothing
Set vMessage = Nothing
WScript.Quit Paladine
Master Poster
Team Colleague
824 posts since Feb 2003
Reputation Points: 211
Solved Threads: 27