Hi,
I'm trying to run a powershell script that checks the free space on server drives and only reports back on ones with more than 75% used. I can get it to report the information from the drives, but i can't get it to filter on anything over 75% or sort it.
Here is the function i have
I have tried running an additional pipe after the select-object with
But it errors with Cannot compare "System.Collections.Hashtable" because it is not IComparable.
Any tips please??
I'm trying to run a powershell script that checks the free space on server drives and only reports back on ones with more than 75% used. I can get it to report the information from the drives, but i can't get it to filter on anything over 75% or sort it.
Here is the function i have
Code:
Function GetDiskSpace
{
Foreach ($s in $servers)
{
$FreeGB = @{Name="FreeSpace(GB)";expression={[math]::round(($_.FreeSpace / 1073741824),2)}}
$TotalGB = @{Name="Capacity(GB)";expression={[math]::round(($_.Capacity/ 1073741824),2)}}
$UsedGB = @{Name="Volume Used(GB)";expression={[math]::round(($_.Capacity/ 1073741824) - ($_.FreeSpace / 1073741824),0)}}
$UsedPerc = @{Name="Used %";Expression={[math]::round((((($_.Capacity/ 1073741824) - ($_.FreeSpace / 1073741824)) / ($_.Capacity / 1073741824)) * 100),0)}}
Get-WmiObject -Class win32_volume -cn $s |
Select-Object @{LABEL='Comptuer';EXPRESSION={$s}},driveletter, label,$FreeGB, $TotalGB,$UsedGB,$UsedPerc
} #end foreach $s
}
I have tried running an additional pipe after the select-object with
Code:
where-object { $UsedPerc -gt 75 }
But it errors with Cannot compare "System.Collections.Hashtable" because it is not IComparable.
Any tips please??
