We would like to create a report that gives us the top X consumers of storage space on our volumes. We can get a list of the users and their space used via Get-NcQuotaReport | select QuotaUsers,DiskUsed. However, the number in the DiskUsed field is left aligned so it does not sort well. We can use a Format-Table to right-align the numbers, but we get an error if we try and sort after the formatting is done. How can we get the disk used right-aligned so we can sort on it?
function Get-Usage{
Get-NcQuotaReport | select QuotaUsers,DiskUsed | format-table QuotaUsers,@{n='Bytes';e={$_.DiskUsed};align='right'}
}
Get-Usage | Sort-Object -Property Bytes
out-lineoutput : The object of type
"Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData" is not valid
or not in the correct sequence. This is likely caused by a user-specified
"format-*" command which is conflicting with the default formatting.
+ CategoryInfo : InvalidData: (:) [out-lineoutput], InvalidOperat
ionException
+ FullyQualifiedErrorId : ConsoleLineOutputOutOfSequencePacket,Microsoft.P
owerShell.Commands.OutLineOutputCommand