I have a similar vbscript to the one RJ provided that pulls a list of servers from a tbl I maintain on our sql boxes to track os and sql updates, ram, etc. The script loops through each server and returns the space infromation and loads it to a second tbl in the db with the server id so the space tbl can be joined to the server tbl. The script worked really well but my DBA has since become a powershell fanatic and replaced it.
Option Explicit
Dim oServerList, oSpaceTable, strServer, strServerID,strFreeSpace,strusedSpace, strDiskSize, strHDD, strTextFilePath, txt
Dim objWMIService, objItem, colItems,objFSO,objTextFile
'open our connections
set oServerList=createobject("adodb.recordset")
oServerList.open "SELECT * FROM [tblServer] WHERE localmonitor = 0" , "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Administration;Data Source=SQLDISTRIB;Application Name=DiskSpace Monitor"
set oSpaceTable=createobject("adodb.connection")
oSpaceTable.open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Administration;Data Source=SQLDISTRIB;Application Name=DiskSpace Monitor"
' set the path for the error log file
strTextFilePath = "D:\CommonTools\Scripts\Log\errorlog.txt"
txt = "ServerID" & vbtab & "Server" & vbtab & "Error Description" & vbcrlf
' loop through or sql server tbl to get the server names we will need to go after.
Do While Not oServerList.EOF
'WScript.Echo oServerList("server").Value
strServer = oServerList("Server")
strServerID = oServerList("ServerID")
'msgbox strserver & " " & strServerID
' turn on our error handling
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & strServer & "\root\cimv2")
If Err.Number <> 0 Then
txt = txt & strServerID & vbtab & strServer & vbtab & Err.Description & vbcrlf
oServerList.MoveNext
Else
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk WHERE DriveType=3")
For Each objItem in colItems
'pctFreeSpace = INT((objItem.FreeSpace / objItem.Size) * 1000)/10
strDiskSize = Int(objItem.Size)
strFreeSpace = Int(objItem.FreeSpace)
strUsedSpace = Int(objItem.Size-objItem.FreeSpace)
strHDD = Replace(objItem.Name,":","")
oSpaceTable.execute "INSERT INTO tblServerSpace ([serverid],[hdd],[totalsize],[freespace],[usedspace]) VALUES ('"& strServerID & "','" & strHDD & "','" & strDiskSize & "','" & strFreeSpace & "','" & strusedSpace & "')"
Next
End If
oServerList.MoveNext
Loop
Set oServerList = Nothing
' write the error log to teh file.
SET objFSO = createobject("Scripting.FileSystemObject")
SET objTextFile = objFSO.CreateTextFile(strTextFilePath)
objTextFile.Write(txt)
objTextFile.Close
SET objTextFile = nothing
wscript.echo txt
wscript.quit