How to create PowerShell outputs to show all data without truncation (results shortened with three dots)

Welcome to the first post of my series on how to get more results from PowerShell.

- How to create PowerShell outputs to show all data without truncation.

This tutorial will show you how to create or edit scripts to ensure you get results without truncation. Truncation is when PowerShell shortens your expected results with three dots.
Truncation of results is really frustrating, but once you know how, it is very easily resolved.


All tutorials in this series -
- How to create PowerShell outputs to show all data without truncation - Link
- How to force PowerShell to display all the properties by default - Link
- How to force PowerShell to export multi-value properties when exporting to csv files - Link

Related PowerShell Tutorials
- How to create basic PowerShell scripts - Link
- How to create basic PowerShell scripts with Export-CSV - Link
- How to create basic PowerShell scripts with Import-CSV - Link


When you start creating PowerShell reports, you will quickly see that there are many different ways to output your results or queries. Most day to day administration will involve simple queries to get the basic details of a mailbox for example.

This simple query will involve using the cmdlet 'Get-Mailbox' with the identity of the mailbox, and output the results to either the screen or a file type (usually txt or csv file).

Below I have run the cmdlet - Get-Mailbox to query the mailbox user - user01 - and output to screen in list format.

Next I will select just three properties to display, the mailbox Display Name, the Primary SMTP Address and all the other email addresses.

Get-Mailbox user01 | fl DisplayName,PrimarySMTPAddress,EmailAddresses

As you can see, the property for the email addresses has been truncated (shortened) and ends with three full stops.

This truncation also happens when outputting to a txt file -
Get-Mailbox user01 | Select DisplayName,PrimarySMTPAddress,EmailAddresses | Out-File C:\Reports\EmailAddress.txt

You can try to change your output formatting by outputting to a string, with a width of 4096 to try and get around column width limits, but this ends up with an even worse output, with both Format List and Format Table.

Fortunately there is a really simple solution, changing the PowerShell preference for the variable - FormatEnumerationLimit.

By default, the PowerShell preference variable - FormatEnumerationLimit - is set to 4 - Link

We can determine the current value by entering the following into a new PowerShell session window -
- As you can see, the result shows our session has the default preference, which is set to 4 -

Unfortunately, this default setting means that the results from many PowerShell commands will be truncated (shortened) with three dots as seen in the previous examples.

By setting the variable -
we can resolve the issue and get all the information. You can run this at anytime or add it to the start of existing scripts.

First enter the variable - (note that the value is negative one)
$FormatEnumerationLimit = -1

Then run your cmdlet - for example
Get-Mailbox user01 | fl DisplayName,PrimarySMTPAddress,EmailAddresses
Now you can see ALL the email addresses.

This also works when exporting to a txt file
Get-Mailbox user01 | fl DisplayName,PrimarySMTPAddress,EmailAddresses | Out-File C:\Reports\EmailAddresses.txt

It is really easy to set the FormatEnumerationLimit variable to -1 as soon as you discover your results are truncated. I will be updating my TechNet scripts with that setting to ensure all the results are shown as expected with my scripts.

Download my scripts below that I have updated with this variable to ensure you get ALL the data.

Exchange Online Configuration Documentation Script - Link

Mailbox Permission Pack for Exchange Online and Exchange On-Premises - Link

Exchange Org documentation script for auditing and creating As Built docos - Link


Congratulations !!!
You now know how to create PowerShell scripts without truncation.


Check out a list of ALL of my tutorials here - Link

1 comment:

  1. This is a good little trick. I always resorted to using the “select-object” piped command, so it would be something similar to get-mailbox -identity user | select-object -expandproperty emailaddresses. Of course the downfall would be that the only thing being returned would be the email addresses