Script to get disk space in MB (including MountPoints).

I'm looking for a simple script to get disk space in MB (including MountPoints).
Below is the latest vbs script I'm going to try:


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

Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk where drivetype <> 5")

WScript.Echo "Name Capacity Free Free %"
For each objDisk in colDisks
percentfree = (objdisk.Freespace / objdisk.Size) * 100
With objDisk
WScript.Echo .DeviceId & " " & pad(FormatNumber(.Size/1048576, 2)) & " " & pad(FormatNumber(.Freespace/1048576, 2)) & " " & FormatNumber(percentfree, 2)
End With

Next

function pad(strText)
strText = Space(12) + strText
strText = Right(strText, 10)
pad = strText
end function

Ref: http://www.computerhope.com/forum/index.php?topic=133037.0
http://ss64.com/nt/for_f.html

Comments

Popular posts from this blog

vRA/vRO workflows

How to generate HPS Report for Windows