I'm trying to get the disk usage from all disks and then send out an email if the disk usage is more than 80% for any of the disks. Using the existing articles, I came up with the below but not able to filter out disks with more than 80% usage. Can some kind soul guide me? TIA
$size = @{label="Size(GB)";expression={[int]($_.Size/1GB)}}
$freeSpace = @{label="FreeSpace(GB)";expression={[int]($_.FreeSpace/1GB)}}
$freeSpacePercent = @{label="FreeSpace(%)";expression={[int]($_.FreeSpace/$_.Size * 100)}}
Get-CimInstance -ClassName Win32_LogicalDisk |
Select-Object -Property DeviceID,VolumeName,$size,$freeSpace,$freeSpacePercent