The best way to show my problem is to show a sample.
When I execute (on Win10 21H2) a PS command like:
Get-PnpDevice | where name -match mass
then in the resulting table some columns are
- wider than necessary
- small then necessary (some values are cut)
How can I tell PS to automatically adjust the columns width to the maximum column it contains?
How can I MANUALLY set the column width of a column width header “mycolumn123” in the result table to 20 chars?
Welcome back to the forum. Long time no see.
There is no general setting telling PowerShell to adjust the output of all cmdlets to the way you prefer. But there’s an easy workaround. You can pipe the output to “
Format-Table -AutoSize” to make that happen. If it’s just for console output you could use the shorter version and pipe it to “
Get-PnpDevice | Where-Object -Property Name -Match -Value Mass | Format-Table -AutoSize
… or - as mentioned - the shorter version …
Get-PnpDevice -FriendlyName *Mass* | ft -a