Authenticate and enumerate the disks on a system (VBScript)

This code can be found in Chapter 1 of Windows Server Cookbook

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the VBScript code from this site.

' From the book "Windows Server Cookbook" by Robbie Allen
' ISBN: 0-596-00633-0

set objLocator = CreateObject("WbemScripting.SWbemLocator")
set objWMI = objLocator.ConnectServer("srv01", "root\cimv2", _
              "srv01\administrator", "net")
set objDisks = objWMI.InstancesOf("Win32_LogicalDisk")
for each objDisk in objDisks
	Wscript.Echo "DeviceID: " & objDisk.DeviceID
	Wscript.Echo "FileSystem: " & objDisk.FileSystem
	Wscript.Echo "FreeSpace: " & objDisk.FreeSpace
	Wscript.Echo "Size: " & objDisk.Size
	WScript.Echo ""
next

This code has been viewed 1172 times.

New from the creators of TechTasks.com: StatSheet.com