$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$strComputer = "localhost"
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\ROOT\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT DeviceID,FreeSpace FROM Win32_LogicalDisk WHERE DeviceID = 'C:'", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
How can I get data(FreeSpace) from $colItems object? Can I do it without using loop?
Try this:
$objWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & '\root\cimv2:Win32_LogicalDisk="C:"')
MsgBox(0, "TEST", "Free Diskspace on C: " & $objWMI.FreeSpace & " bytes / " & Round($objWMI.FreeSpace / 1024^2) & " mb")
Br,
UEZ