PSTree.Format.ps1xml

<?xml version="1.0" encoding="utf-8"?>
<Configuration>
  <ViewDefinitions>
    <View>
      <Name>treeview</Name>
      <ViewSelectedBy>
        <TypeName>PSTreeDirectory</TypeName>
        <TypeName>PSTreeFile</TypeName>
      </ViewSelectedBy>
      <TableControl>
        <TableHeaders>
          <TableColumnHeader>
            <Label>Mode</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Hierarchy</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Size</Label>
            <Alignment>Right</Alignment>
          </TableColumnHeader>
        </TableHeaders>
        <TableRowEntries>
        <TableRowEntry>
            <TableColumnItems>
            <TableColumnItem>
                <ScriptBlock>
                    return $_.Instance.Mode
                </ScriptBlock>
            </TableColumnItem>
            <TableColumnItem>
                <PropertyName>Hierarchy</PropertyName>
            </TableColumnItem>
            <TableColumnItem>
                <ScriptBlock>
                    # Inspired from https://stackoverflow.com/a/40887001/15339544
 
                    $suffix = "Bytes", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"
                    $index = 0
                    $length = [int64] $_.Length
 
                    while ($Length -ge 1kb) {
                        $Length /= 1kb
                        $index++
                    }
                    return [string]::Format(
                        '{0} {1}', [math]::Round($Length, 2), $suffix[$index]
                    )
                </ScriptBlock>
            </TableColumnItem>
            </TableColumnItems>
        </TableRowEntry>
        </TableRowEntries>
      </TableControl>
    </View>
  </ViewDefinitions>
</Configuration>