I am new to Powershell and have been using the following snippet of code to pull the site quota information from my farm
$GetStorage = @{Name="Storage"; Expression={"{0:N2} MB" -f ($_.Usage.Storage/1048576)}}
$GetQuota = @{Name="Quota"; Expression={"{0:N2} MB" -f ($_.Quota.StorageMaximumLevel/1048576)}}
$GetUsage = @{Name="Used"; Expression={"{0:P2}" -f ($_.Usage.Storage/$_.Quota.StorageMaximumLevel)}}
Get-SPSite | Select-object URL,$GetStorage, $GetQuota, $GetUSage | Sort-Object Storage | Format-Table -AutoSize
This produces output like this:
Url Storage Quota Used
--- ------- ----- ----
https://intdomain.com/sites/digital 156.93 MB 5,120.00 MB 3.07 %
https://intdomain.com/sites/brazil 340.42 MB 5,120.00 MB 6.65 %
https://intdomain.com/sites/pos 51.90 MB 2,560.00 MB 2.03 %
https://intdomain.com/sites/EMEA 549.05 MB 2,560.00 MB 21.45 %
https://intdomain.com/sites/APAC 6,918.31 MB 10,240.00 MB 67.56 %
https://intdomain.com/sites/pr 655.82 MB 2,560.00 MB 25.62 %
https://intdomain.com 74.04 MB 2,560.00 MB 2.89 %
As you'll see from my code, I'm trying to sort by the storage consumed, and it's only sorting it via the first number displayed - hence I have 6GB then 600MB
I'd like to be able to sort by this the quota used (the % column) but I have the same issue. The numbers do not sort in the right way.
I believe that it's because the numbers being returned are "Hash Tables" and not Integers.
Could someone help me correct the output so that it's sorted correctly?