Jonathan
Jonathan

Reputation: 2845

PowerShell output lines truncated

When I run a PowerShell cmdlet, often an output line is wider than will fit in the PS window. In this case, the output terminates with ... and the balance of the line is not displayed. Is there any way of seeing this output? I see this specifically in PowerShell V6 on Windows 10. For example, I run the cmdlet Get-ChildItem Env: and several of the lines output by the cmdlet are too long to fit on the screen.

Upvotes: 0

Views: 5292

Answers (2)

Jonathan
Jonathan

Reputation: 2845

The correct way of handling this problem is:

Get-ChildItem -Path Env: | Format-Table -Property Name, Value -Wrap

The point I missed because of my poor knolwedge of PowerShell was that it was necessary to format the output before printing, thus bypassing the default formatting provided by PowerShell.

Upvotes: 2

Mark
Mark

Reputation: 434

If you have a single line of text you may be able resolve it by piping it to

| out-string -Width 160

(Of course, you might have to play with the 160 to get it right)

If you have a collection of items, and it's only showing the first 3, you probably want to set

$FormatEnumerationLimit=-1

-1 here is for no limit- you could set it to any number. Lastly, you have a table your creating and the columns aren't wide enough, try

| Format-Table -AutoSize

Upvotes: 1

Related Questions