Microsoft Virtualization Discussions

Get-NaQuotaReport and sort by DiskUsed

ROBINMALIK
3,911 Views

Hi all,

I'm using the latest version of the toolkit (2.0.0) and am having difficulty sorting with any sort of sense, by DiskUsed when using the Get-NaQuotaReport cmdlet.

For example:

Get-NaQuotaReport | Where-Object { $_.QuotaType -eq "tree" } | Sort DiskUsed

This results in a list of entries, with all those having "0" DiskUsed at the top and then (for example):

103.2 MB

1.1 MB

14.0 GB

17.9 MB

261.5 MB

396.0 KB

37.8 GB

Confused?

Trying this doesn't work either:

Get-NaQuotaReport | Where-Object { $_.QuotaType -eq "tree" } | Select QTree,DiskUsed | Sort DiskUsed

Again, all results of 0 first, and then:

108249088

1179648

15029035008

18776064

274227200

Huh? Help much appreciated!

1 ACCEPTED SOLUTION

cknight
3,912 Views

PowerShell is sorting the numerical fields alphabetically.  Try this:

Get-NaQuotaReport | Where-Object { $_.QuotaType -eq "tree" } | Sort { [decimal] $_.DiskUsed }

View solution in original post

2 REPLIES 2

cknight
3,913 Views

PowerShell is sorting the numerical fields alphabetically.  Try this:

Get-NaQuotaReport | Where-Object { $_.QuotaType -eq "tree" } | Sort { [decimal] $_.DiskUsed }

ROBINMALIK
3,912 Views

Thank you very much!

Public