?
Solved

VBScript To Check Hard Disk Space Available on Network Servers

Posted on 2005-03-02
1
Medium Priority
?
12,651 Views
Last Modified: 2013-04-08
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!

Regards
Richard
0
Comment
Question by:rabelle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
Chuckbuchan earned 750 total points
ID: 13521144
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
xnumber=1
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
strcomputer=x

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")
next
introw=introw+1
xnumber=xnumber+1

Set colItems = Nothing
Set objWMIService = Nothing

loop
set objOutputFile = Nothing
Set objFSO = Nothing




objOutputFile.Close
'Script ends here
wscript.echo " script done"
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Introduction to Processes
Starting up a Project
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question