Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - diskspace on Exchange Servers

Reply
 
Old 12-04-2008   #1 (permalink)
simalt


 
 

diskspace on Exchange Servers

I have a script here to check diskspace but its all over the place
unfortunately.

I am trying to only query the E, G and I drives of a list of servers.
Some of these servers have only E and G drives whilst others have E, G
and I drives. Basically these are exchange log areas and we are
trying to keep an eye out on the diskspace so it does not run out on a
daily report.

If any one can help I would appreciate it please. The script is below
which at the moment list percents and all drive letters at the
begining but I need to maybe put a case statement in to only check for
the needed drive letters and how to read the list of servers in
through a text file outputting drive letter such as

E: freespace nnnn percent free

Thanks.

Simon

-----------------------------------------------------------------

Const HARD_DISK = 3

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root
\cimv2")

Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk Where DriveType = " & HARD_DISK
& "")


For Each objDisk in colDisks
'to get GB size, divide by 1073741824 (same as
dividing space by
' 1024 / 1024 / 1024)
strDiskDrive = objDisk.DeviceID
strDiskUsed = FormatNumber((objDisk.Size -
objDisk.FreeSpace) / 1073741824)
strDiskSize = FormatNumber(objDisk.Size /
1073741824,2)
strDiskFree = FormatNumber(objDisk.Freespace /
1073741824,2)
strPercFree = FormatNumber(objDisk.FreeSpace/
objDisk.Size,2)
strPercFree = strPercFree * 100 'multiply percent by
100 to get whole number
wscript.echo strComputer & vbtab & " " & strDiskDrive
& " " & strPercFree & "% free."
Next


For Each objDisk in colDisks
Wscript.Echo "DeviceID: "& vbTab & objDisk.DeviceID
Wscript.Echo "Free Disk Space: "& vbTab & objDisk.FreeSpace/
1048576
Next


wscript.echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++"

For Each objDisk in colDisks

If objDisk.DeviceID = "E:" Then
'wscript.Echo objDisk.DeviceID & vbtab & objDisk.FreeSpace/1048576
mynum=objDisk.Freespace
Myroundnum=Int(mynum/1048576)+1
wscript.Echo objDisk.DeviceID & vbtab & Myroundnum
End if

If objDisk.DeviceID = "G:" Then
mynum=objDisk.Freespace
Myroundnum=Int(mynum/1048576)+1
wscript.Echo objDisk.DeviceID & vbtab & Myroundnum
End If

If objDisk.DeviceID = "I:" Then
mynum=objDisk.Freespace
Myroundnum=Int(mynum/1048576)+1
wscript.Echo objDisk.DeviceID & vbtab & Myroundnum
End If
Next

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
diskspace on shares VB Script
configuring the diskspace bar from the drive tile General Discussion
Diskspace cleanup = strange problem General Discussion
Finding Exchange 2003 Servers in AD PowerShell
Diskspace growing 1 GB/day (or more) Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46