Converts bytes to largest possible units, to improve readability.
Format-ByteUnits.ps1 [-Bytes] <BigInteger> [-Precision <Byte>] [-UseSI] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
Format-ByteUnits 65536
64KB
Format-ByteUnits 9685059 -dot 1 -si
9.2 MiB
ls *.log |measure -sum Length |select -exp Sum |Format-ByteUnits -dot 2 -si
302.39 MiB
The number of bytes to express in larger units.
Type: BigInteger
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
The maximum number of digits after the decimal to keep. The default is 16 (the maximum).
Type: Byte
Parameter Sets: (All)
Aliases: Digits, dot
Required: False
Position: Named
Default value: 16
Accept pipeline input: False
Accept wildcard characters: False
Displays unambiguous SI units (with a space). By default, native PowerShell units are used (without a space, to allow round-tripping the value, though there may be significant rounding loss depending on precision).
Type: SwitchParameter
Parameter Sets: (All)
Aliases: si
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.