Private/Format-TechCareSize.ps1

function Format-TechCareSize {
    <#
    .SYNOPSIS
        Convierte un numero de bytes en un texto legible.
    .DESCRIPTION
        El formato respeta la cultura de la sesion, de modo que un tecnico espanol
        lee "2,00 GB" y uno estadounidense "2.00 GB". El informe JSON publica
        siempre los bytes en crudo, que es el campo que debe parsearse.
    #>

    [CmdletBinding()]
    [OutputType([string])]
    param(
        [Parameter(Mandatory)]
        [int64]$Bytes
    )

    if ($Bytes -ge 1GB) { return ('{0:N2} GB' -f ($Bytes / 1GB)) }
    if ($Bytes -ge 1MB) { return ('{0:N2} MB' -f ($Bytes / 1MB)) }
    if ($Bytes -ge 1KB) { return ('{0:N2} KB' -f ($Bytes / 1KB)) }
    return ('{0} B' -f $Bytes)
}