Thursday, March 28, 2024
HomePowershellFormat the output of a string in a number of columns with...

Format the output of a string in a number of columns with PowerShell · Mike F. Robbins


In my earlier weblog article, I used the PowerShell Format-Broad cmdlet to format the output of a
string in a number of columns. Whereas Format-Broad isn’t a command that I’ve used extensively, the
habits wasn’t what I anticipated.

If you pipe object-based output aside from a string from any PowerShell command to
Format-Broad, it produces the specified outcomes.

Get-PSDrive | Format-Broad -Column 2

I’ll pipe the next to Get-Member to substantiate that it’s a string.

'one', 'two', 'three', '4' | Get-Member

format-wide2a.jpg

If you use Format-Broad with a string, it doesn’t break up the outcomes into a number of columns.

'one', 'two', 'three', '4' | Format-Broad -Column 2

format-wide3a.jpg

Extra testing and nonetheless not the outcomes I anticipated.

'one', 'two', 'three', '4' | Format-Broad -Column 2 -Pressure
'one', 'two', 'three', '4' | Format-Broad -Property $_ -Column 2
'one', 'two', 'three', '4' | Format-Broad -Property $_ -Column 2 -Pressure
'one', 'two', 'three', '4' | Format-Broad -Property {$_} -Column 2

format-wide4a.jpg

To provide output with a number of columns from a string utilizing Format-Broad, you must specify the
present object variable inside curly braces as the worth for the Property parameter together with the
Pressure parameter.

'one', 'two', 'three', '4' | Format-Broad -Property {$_} -Column 2 -Pressure

format-wide5a.jpg

The next video demonstrates the instructions used on this weblog
article.


Jeff Hicks printed a follow-up
weblog article that includes a perform
to format the output of strings in a number of columns with PowerShell.

µ



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments