I'm need to scan various remote servers for the available drive space of all
drives on a each server.

Executing the script from my machine I'm able to capture the drive info for
remote servers if I pass the script a list of server names and drive letters
i.e. \\servername\c$

But, given the number of servers I have to scan and not knowing what drives
are used on each server I'd prefer to simply use a list of server names and
dynamically determine which drives are used on that server and subsequently
capture the available drive space for each.

As far as I can tell the fso.Drives collection is only relevant to the local
machine. Is there a way to collect the available drive info on a remote
server - in vbs or otherwise??

Thanks in advance.
KC

Re: Scanning Servers For Available Drive Space? by BrianEdwardo

BrianEdwardo
Mon May 24 11:55:09 CDT 2004

Yep, below is one I wrote that uses a feed file, just a text file with a
server name on each line and then outputs to a csv file.
The most import thing with this is hard disk type, you want 3 or you will
get floppies, cdroms.
****
dim ofs,ofsout,readin,readout,ip,strcomputer,today,ntime
on error resume next

Const HARD_DISK = 3
Const CONVERSION_FACTOR = 1048576

today = date
ntime = now
set ofs = createobject("scripting.filesystemobject")
set readin = ofs.opentextfile("c:\vbs\feed\pgh-valid.txt",1,false)
'set readin = ofs.opentextfile("c:\vbs\feed\testpush.txt",1,false)

set ofsout = createobject("scripting.filesystemobject")
set readout = ofsout.opentextfile("c:\vbs\output\freespace.csv",2,true)
readout.writeline today&" "&ntime
readout.writeline
"servername"&","&"Drive"&","&"FreeSapce"&","&"TotalDiskSize"

while not readin.atendofstream
strcomputer = readin.readline()

'Get disk ID and space information
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_logicalDisk
where drivetype = " & HARD_DISK & "")
'Set colItems = objWMIService.ExecQuery("Select * from Win32_logicalDisk
where drivetype = 3 and deviceid = C:",,48)
For Each objItem In colItems
diskid = objitem.deviceid
freemegabytes = objitem.freespace / conversion_factor
diskspace = round(freemegabytes,0)
totalspace = round(objitem.size/ conversion_factor)
readout.writeline strcomputer&","&diskid&","& diskspace &","&totalspace
Next
Set objWMIService = Nothing
Set colItems = Nothing
set diskspace = nothing

If (err.number <> 0)then
error.clear
end if

wend
readin.close()
readout.close()
wscript.echo "done"
****

--
BRIAN EDWARDO
"K_Cooper" <kcooper2@NOSPAM.austin.NOSPAM.rr.com> wrote in message
news:OWbec1TQEHA.368@TK2MSFTNGP09.phx.gbl...
> I'm need to scan various remote servers for the available drive space of
all
> drives on a each server.
>
> Executing the script from my machine I'm able to capture the drive info
for
> remote servers if I pass the script a list of server names and drive
letters
> i.e. \\servername\c$
>
> But, given the number of servers I have to scan and not knowing what
drives
> are used on each server I'd prefer to simply use a list of server names
and
> dynamically determine which drives are used on that server and
subsequently
> capture the available drive space for each.
>
> As far as I can tell the fso.Drives collection is only relevant to the
local
> machine. Is there a way to collect the available drive info on a remote
> server - in vbs or otherwise??
>
> Thanks in advance.
> KC
>
>



Re: Scanning Servers For Available Drive Space? by R

R
Mon May 24 11:56:03 CDT 2004

KC -

Give my script a try here...
http://uphold2001.brinkster.net/vbshf/forum/forums/thread-view.asp?tid=8&posts=1

this one can send a summary email after it runs. Pretty nice!

Rob


"K_Cooper" <kcooper2@NOSPAM.austin.NOSPAM.rr.com> wrote in message
news:OWbec1TQEHA.368@TK2MSFTNGP09.phx.gbl...
> I'm need to scan various remote servers for the available drive space of
all
> drives on a each server.
>
> Executing the script from my machine I'm able to capture the drive info
for
> remote servers if I pass the script a list of server names and drive
letters
> i.e. \\servername\c$
>
> But, given the number of servers I have to scan and not knowing what
drives
> are used on each server I'd prefer to simply use a list of server names
and
> dynamically determine which drives are used on that server and
subsequently
> capture the available drive space for each.
>
> As far as I can tell the fso.Drives collection is only relevant to the
local
> machine. Is there a way to collect the available drive info on a remote
> server - in vbs or otherwise??
>
> Thanks in advance.
> KC
>
>