VBScript To Check Hard Disk Space Available on Network Servers

I need a vbscript to check on various servers (server1, server2, server3, server4) to see what hard disk space they have available and report the answer back to a text file (G:\Reports\DiskSpace.txt). The script will be run from a monitoring PC on the network with UNC access to all 4 servers.

This file needs to keep the previous 7 days data, so the file would look a bit like the following:

** Start of text file **
Report as at 02/03/2005 07:00
server1 = 3,000mb
server2 = 4,000mb
server3 = 5,000mb
server4 = 2,000mb

Report as at 01/02/2005 07:00
server1 = 3,000mb
server2 = 4,000mb
server3 = 5,000mb
server4 = 2,000mb

** End of text file **

Hope someone can help me!

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

try this and let meknow if it gives you any error.
Create an excel file and put the names of the computer in a column, in my example is column4

Dim objExcel, strPathExcel,strCN,xnumber
Dim objFile, strGuyFile, intRow
intRow = 4
Set objExcel = CreateObject("Excel.Application")
strPathExcel = "c:\My Documents\list.xls"   'the path to your excel file
objExcel.Workbooks.open strPathExcel
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)

do while introw<=106  'suppose you have 106 computers
x = Trim(objSheet.Cells(intRow, 4).Value)  'suppose the column4 is where the computer names are

on error resume next

Set Service = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2")
Set objFSO = Wscript.CreateObject("Scripting.FileSystemObject")
'Change the path and filename to that of the file you want to write the info to
Set objOutputFile = objFSO.CreateTextFile("G:\Reports\Diskspace.txt")

    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    objOutputFile.WriteLine(xnumber & " " & "Computer: " & strComputer)
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk WHERE Description = 'Local Fixed   Disk'", "WQL", _
     wbemFlagReturnImmediately + wbemFlagForwardOnly)
    objOutputFile.WriteLine("    Drive Info")
    For Each objItem in colItems
    objOutputFile.WriteLine(vbTab & "DeviceID: " & objItem.DeviceID & " Size: " & objItem.Size/1000000000 & "  Gigs" )
'   objOutputFile.WriteLine(vbTab & " Disk Space:  " & objitem.freespace/1000000000 & " Gigs")

Set colItems = Nothing
Set objWMIService = Nothing

set objOutputFile = Nothing
Set objFSO = Nothing

'Script ends here
wscript.echo " script done"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.