Created
July 29, 2019 10:01
-
-
Save raandree/bf804ad22eff23bef38e9b6d07f9030a to your computer and use it in GitHub Desktop.
PowerShell Formatter for Measure-Object to show sizes also in MB, GB or TB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<Configuration> | |
<ViewDefinitions> | |
<View> | |
<Name>Microsoft.PowerShell.Commands.GenericMeasureInfo</Name> | |
<ViewSelectedBy> | |
<TypeName>Microsoft.PowerShell.Commands.GenericMeasureInfo</TypeName> | |
</ViewSelectedBy> | |
<ListControl> | |
<ListEntries> | |
<ListEntry> | |
<ListItems> | |
<ListItem> | |
<PropertyName>Count</PropertyName> | |
</ListItem> | |
<ListItem> | |
<Label>Average</Label> | |
<ScriptBlock> | |
if (-not $Global:FormatQuantifier) | |
{ | |
$Global:FormatQuantifier = 'GB' | |
} | |
if ($_.Average -ne $null) | |
{ | |
"{0} ({1:N2} $Global:FormatQuantifier)" -f $_.Average, ($_.Average / "1$Global:FormatQuantifier") | |
} | |
</ScriptBlock> | |
</ListItem> | |
<ListItem> | |
<Label>Sum</Label> | |
<ScriptBlock> | |
if ($_.Sum -ne $null) | |
{ | |
"{0} ({1:N2} $Global:FormatQuantifier)" -f $_.Sum, ($_.Sum / "1$Global:FormatQuantifier") | |
} | |
</ScriptBlock> | |
</ListItem> | |
<ListItem> | |
<Label>Maximum</Label> | |
<ScriptBlock> | |
if ($_.Maximum -ne $null) | |
{ | |
"{0} ({1:N2} $Global:FormatQuantifier)" -f $_.Maximum, ($_.Maximum / "1$Global:FormatQuantifier") | |
} | |
</ScriptBlock> | |
</ListItem> | |
<ListItem> | |
<Label>Minimum</Label> | |
<ScriptBlock> | |
if ($_.Minimum -ne $null) | |
{ | |
"{0} ({1:N2} $Global:FormatQuantifier)" -f $_.Minimum, ($_.Minimum / "1$Global:FormatQuantifier") | |
} | |
</ScriptBlock> | |
</ListItem> | |
<ListItem> | |
<PropertyName>Property</PropertyName> | |
</ListItem> | |
</ListItems> | |
</ListEntry> | |
</ListEntries> | |
</ListControl> | |
</View> | |
</ViewDefinitions> | |
</Configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment