Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script to check drive space on removable drives only

Status
Not open for further replies.

k33

Technical User
Apr 10, 2003
20
0
0
US
The following code is provided by Microsoft scripting. I want to modify to check for low disk space ONLY on specified drives via user input OR only on removable drives. Either would work. Any suggestions?

Const CONVERSION_FACTOR = 1048576
Const WARNING_THRESHOLD = 100
Computer = "Workstation1"
Set objWMIService = GetObject("winmgmts://" & Computer)
Set colLogicalDisk = objWMIService.InstancesOf("Win32_LogicalDisk")
For Each objLogicalDisk In colLogicalDisk
FreeMegaBytes = objLogicalDisk.FreeSpace / CONVERSION_FACTOR
If FreeMegaBytes < WARNING_THRESHOLD Then
Wscript.Echo objLogicalDisk.DeviceID & &quot; is low on disk space.&quot;
Else
Wscript.Echo objLogicalDisk.DeviceID & &quot; has adequate disk space.&quot;
End If
Next


Thanks
 
For removable drives add the lines marked with ***.

Const CONVERSION_FACTOR = 1048576
Const WARNING_THRESHOLD = 100
Computer = &quot;Workstation1&quot;
Set objWMIService = GetObject(&quot;winmgmts://&quot; & Computer)
Set colLogicalDisk = objWMIService.InstancesOf(&quot;Win32_LogicalDisk&quot;)
For Each objLogicalDisk In colLogicalDisk

*** If objLogicalDisk.DriveType = &quot;2&quot; then

FreeMegaBytes = objLogicalDisk.FreeSpace / CONVERSION_FACTOR
If FreeMegaBytes < WARNING_THRESHOLD Then
Wscript.Echo objLogicalDisk.DeviceID & &quot; is low on disk space.&quot;
Else
Wscript.Echo objLogicalDisk.DeviceID & &quot; has adequate disk space.&quot;
End If

*** End If

Next
 
Thanks!! That worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top