Hi Rcarlson ,
Thanks for the VB script. It works great for me. I took the liberty to parametize the server name so that I can use for multiple servers and drives. (Sorry Aaron Myers, I am one step ahead of you.) Here is the modified script:
' Returns drive size results to an HTML file.
On Error Resume Next
' HTML coding
const H_HEAD = "<HTML><HEAD>"
const T_HEAD = "<TITLE>STATUS REPORT</TITLE></HEAD>"
const B_HEAD = "<BODY BACKGROUND=one.jpg><CENTER><H3>SERVER DISK SPACE UTILIZATION REPORT - - DATE: "
const H_CLOSE = "</CENTER></BODY></HTML>"
' HTML TABLE CODES
const S_TABLE = "<TABLE BORDER=4 CELLPADDING=3>"
const T_TABLE = "<TR><TH>FILE NAME</TH><TH>STATUS</TH></TR>"
const E_TABLE = "</TABLE><BR>"
' HTML SUCCESS OR FAILURE CODE
const F_SUCCESS = "<TD ALIGN=CENTER><FONT COLOR=GREEN>OK</FONT></TD></TR>"
const F_FAILED = "<TD ALIGN=CENTER BGCOLOR=WHITE><FONT COLOR=RED SIZE=+1><B>FAILED</B></FONT></TD></TR>"
' Conversion codes Bites to Megabytes and 2000 megabytes threshold
const CONVERSION_FACTOR = 1048576
const WARNING_THRESHOLD = 2000
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNewFile = objFSO.CreateTextFile("statusSize.htm")
objNewFile.WriteLine H_HEAD
objNewFile.WriteLine T_HEAD
objNewFile.WriteLine B_HEAD & Now() & "</H3>"
objNewFile.WriteLine S_TABLE
'*** Start building display rows ***
objNewFile.WriteLine "<TR><TD>SERVER</TD> <TD>DRIVE</TD> <TD>DESC</TD> <TD>Total Size MB</TD> <TD>FREE MB</TD> <TD>STATUS</TD></TR>"
'--- Enter as many server names and drives as you like ---
Call BuildRow("servername", "C:", "Windows")
objNewFile.WriteLine "<TR></TR>"
Call BuildRow("servername", "E:", "Application")
'-------------------------------------------------------
objNewFile.WriteLine E_TABLE
objNewFile.WriteLine H_CLOSE
const MAXIMIZE_WINDOW = 3
Set objNetwork = Wscript.CreateObject("Wscript.Network")
Set objShell = Wscript.CreateObject("Wscript.Shell")
objShell.Run "statusSize.htm", MAXIMIZE_WINDOW
STOP
Sub BuildRow(pvsComputer, pvsDriveLetter, pvsDriveDesc)
Dim FreeMegaBytes
Dim SizeMegaBytes
Dim objWMIService
Dim colProcesses
Dim objLogicalDisk
Set objWMIService = GetObject("winmgmts:\\" & pvsComputer)
Set colProcesses = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process")
'-- Drive Letter --
'------------------
Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='" & pvsDriveLetter & "'")
FreeMegaBytes = objLogicalDisk.FreeSpace / CONVERSION_FACTOR
SizeMegaBytes = objLogicalDisk.Size / CONVERSION_FACTOR
If FreeMegaBytes < WARNING_THRESHOLD Then
strColor = "RED"
Else
strColor = "YELLOW"
End If
objNewFile.WriteLine "<TR BGCOLOR=" & strColor & " >"
objNewFile.WriteLine "<TD>" & pvsComputer & "</TD>"
objNewFile.WriteLine "<TD>" & pvsDriveLetter & "</TD>"
objNewFile.WriteLine "<TD>" & pvsDriveDesc & "</TD>"
objNewFile.WriteLine "<TD>" & Int(SizeMegaBytes) & "</TD>"
objNewFile.WriteLine "<TD>" & Int(FreeMegaBytes) & "</TD>"
If strColor = "RED" Then
objNewFile.WriteLine "<TD>" & "LOW" & "</TD>"
Else
objNewFile.WriteLine "<TD>" & "OK" & "</TD>"
End If
objNewFile.WriteLine "</TR>"
'*** End building display rows ***
End Sub