3

I use a number of cmdlets that display data in a table of 4-5 columns by default. Some of this data was frequently larger than the default column width and got truncated, but that was okay because the start of each value is the most useful part (e.g. when trying to distinguish email addresses all from the same domain).

With the upgrade to Windows 10, the default column width seems to have increased. This leaves me with extra-wide columns which show more characters than I strictly need, but also has the unfortunate side-effect that the rightmost columns are not output since they get "pushed" off the screen.

As a visual example, in Windows 8 I had something like this:

Column 1    Column 2      Column 3      Column 4
--------    --------      --------      --------
Data        Lorem ip...   Lorem ip...   Important data

Now in Windows 10 I get this:

Column 1    Column 2                                     Column 3
--------    --------                                     --------    
Data        Lorem ipsum dolor sit amet consectetur ad... Lorem ipsum dolor sit amet...

Where the middle columns can be as wide as 64 characters, preventing the later columns from being shown. Simply re-ordering the columns doesn't help as I still need at least the first several characters from all the columns.

Is there a way I can force format-table or some other display cmdlet to truncate columns after a set value (say, 20 characters)? Preferably some kind of parameter I'm missing that controls how the data is displayed.

1 Answer 1

5

For Format-Table you only have a few options. -AutoSize will make it look nicer and not as spread out and if you throw -Wrap on there as well, it can greatly help.

Your other option is to do a custom table. An example is shown below

$a = @{Expression={$_.Name};Label="Process Name";width=25}, `
@{Expression={$_.ID};Label="Process ID";width=15}, `
@{Expression={$_.MainWindowTitle};Label="Window Title";width=40}

Get-Process | Format-Table $a

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .