Posts

Showing posts from September, 2016

wmic logicaldisk get Name,Size

wmic logicaldisk get Name,Size

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/inde

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/inde