Powershell

How to fix Truncated PowerShell Output

If you are PowerShell lover like me, then you will be well aware of getting a truncated PowerShell Output from PowerShell console.

It’s not an error or problem with the PowerShell its all depend on the width of your PowerShell console windows. If you increase the width, you will be able to get more text, and if you decrease the width, less text will be visible.

There will be times when even if you increase the console width to its maximum 100% still some text will be truncated and you might feel like you are stuck. Do not worry I will show you ways to fix this and get your desired result when outputting something from PowerShell.

Fixing PowerShell Truncation By AutoSize & Wrap

To fix the Truncated PowerShell Output issue first we have to know how PowerShell output the result. By default PowerShell output the result as TableView and it only shows you the outcome until the width of your PowerShell console and truncates the remaining outcome.

Recommended For You:  Integrating Hyper-V and Azure Backup with PowerShell: A Comprehensive Guide

We can fix it by using Wrap and Autosize switches with the Format-Table parameter.

As you can see below PowerShell is truncating the result and I will fix it by adding Wrap and Autosize switches to the Format-Table parameter.

Get-EventLog -LogName Application -Newest 5
Format-Table

As you can see below the truncation was quickly fixed by adding just two extra switches AutoSize and Wrap with the Format-Table command.

Get-EventLog -LogName Application -Newest 5 | Format-Table -Wrap -Autosize
AutoSize-Wrap

If you want o know more about Format-Table PowerShell command, please visit.

Fixing PowerShell Truncation By Format Enumeration Limit

What if you want the Powershell output in ListView instead of TableView. ListView doesn’t have AutoSize and Wrap switches in its arsenal like TableView.

Below I am trying to get the information about a service called RpcEptMapper in ListView but the result is getting truncated.

Get-Service | where name -like "*rpc*" | fl
PowerShell-ListView

Let’s fix Truncated PowerShell Output by setting up the value of a variable called “FormatEnumerationLimit”.

By default, the value of this variable is equal to 4. It’s mean it will only show the first four items in the array, and remaining values in the result will get truncated. To get all the values we have to set the value of this variable to -1.

Recommended For You:  How to Install Chocolatey using PowerShell

Let’s set its value but before we set the value it’s a good idea to know what is its current value. In PowerShell, if you want to see the value of any variable, type its name in the console and add $ sign before its name and press enter you will get its value.

$FormatEnumerationLimit

As you can see the default value is 4 let’s make it -1 and check its value again.

FormatEnumerationLimit
$FormatEnumerationLimit = -1
FormatEnumerationLimit-1

Now the value is set to -1. Let’s rerun our previous command

Get-Service | where name -like "*rpc*" | fl
PowerShell-Result

Hurry, we fixed the PowerShell truncation issue successfully.
Thanks for reading, and if you still face any issue feel free to leave comments, I will reply as soon as possible.

It’s also a great idea to check our Home page for new and interesting posts.

Muhammad Faizan

Hi, My name is Muhammad Faizan and i have spent last 15 years working as System Administrator mainly with Microsoft Technologies. I am MCSE, MCTP, MCITP, certified professional. I love scripting and Powershell is the scripting language i am in love with.

Related Articles

2 Comments

  1. Useful information.

    The example command in the ‘Format-Table -Wrap -AutoSize’ states ‘Format-List’ instead of ‘Format-Table’.

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also
Close
Back to top button