I’m using a hashtable for custom formatting of Format-Table output.
The table input is a System.IO.FileInfo array, and I need columns showing file name, last write time, and file size. My code so far:
$queue = Find-FilesToUpload -server $server | Sort-Object -property lastWriteTime | `
Format-Table -property name, lastWriteTime,
@{name = "Bytes"; expression = {$_.length}; alignment="right"; width=15; format="n0"} | `
Out-Host -paging
The output looks like this:
Name LastWriteTime Bytes
---- ------------- -----
pierson.ogg 8/23/2023 2:06:08 PM 460,664
ohiamsoh.htm 8/23/2023 2:06:55 PM 3,501
The columns are so close together that they can be hard to read with large tables. So I’m trying to put more space between columns, something like this:
Name LastWriteTime Bytes
---- ------------- -----
pierson.ogg 8/23/2023 2:06:08 PM 460,664
ohiamsoh.htm 8/23/2023 2:06:55 PM 3,501
Is adding more inter-column space possible with Format-Table? Neither the -AutoSize parameter or “width” argument made any difference.
I also tried the field width component that I would normally use with the string -f format operator, but couldn’t find a syntax that worked.