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

1 Answer 1

3
$volumes = Get-Volume foreach ($volume in $volumes) { if ($volume.DriveLetter -notlike "") {$volume.DriveLetter + " has " + $volume.SizeRemaining + " bytes free of " + $volume.Size + " bytes total"} } 
1
  • 1
    And if volume not mounted on drive letter but on some dir? Commented Sep 28, 2022 at 18:42

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.