Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

VBScript To Check Hard Disk Space Available on Network Servers

Posted on 2005-03-02
1
Medium Priority
?
12,724 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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
No other job is as rewarding and demanding as building an iPhone app is. It is not really in the hands of the developer for the success of an iPhone app. Many factors operate jointly for every iOS application's success in the market.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Loops Section Overview

580 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