1

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

Newb_969
  • 21
  • 1

1 Answers1

3
$volumes = Get-Volume
foreach ($volume in $volumes) { 
if ($volume.DriveLetter -notlike "") {$volume.DriveLetter + " has " + $volume.SizeRemaining + " bytes free of " + $volume.Size + " bytes total"}
}
batistuta09
  • 8,981
  • 10
  • 23