I am in need to check free space on servers but I am getting more than enough details.
DeviceID : C: DriveType : 3 ProviderName : FreeSpace : 76691152896 Size : 160482455552 VolumeName :
I am having a few queries: 1: I want every drive detail, not only for drive C 2: I don't need extra details like above, I only need the DeviceID and FreeSpace and Size.
I am using the below code: $Report=Get-WmiObject win32_logicaldisk -ComputerName 'servername' -Filter "Drivetype=3" -ErrorAction SilentlyContinue | Where-Object {($.freespace/$.size) -le '0.5'} $View=($Report.DeviceID -join ",").Replace(":","") if($Report) { Echo $Report }
The above code returns result only if the freespace of disk is less than 50%
The above code gives me the below result DeviceID : C: DriveType : 3 ProviderName : FreeSpace : 76691152896 Size : 160482455552 VolumeName :
Kindly help me on this. TIA