In the below code, if I add a where-object, -lt & -gt are giving opposite of expected results.
I'm sure the reason is I'm stupid, but in what specific way am I messing up?
This part gives the expected results, where in my case, the single drive has %Free of 39.8
Get-WmiObject -Namespace root\cimv2 -Class win32_logicaldisk | where-object -Property drivetype -eq 3 |
format-table deviceid,
@{n='GB Capacity';e={$_.size/1gb}},
@{n='GB Free';e={$_.freespace/1gb}},
@{n='%Free';e={($_.freespace/$_.size)*100}}
But adding this
| where {$_.'%Free' -gt 10}
Results in no output. In fact
| where {$_.'%Free' -gt 0}
Produces no results. Instead I have to use
| where {$_.'%Free' -lt 0}
Powershell thinks %Free is a negative number, I guess?