Viewing Truncated PowerShell Output

Sometimes PowerShell truncates output, and if you don’t realise what’s going on, you’ll never get it to show.

Where you’re expecting potentially lots more text, PowerShell replaces it with a single lousy ellipsis, cruelly taunting you.

Column Width

If it’s just a column width problem, the fix is simple enough: just pipe to out-string and add the width parameter.

Before:

PS > Get-CsAnalogDevice | ft Identity,RegistrarPool

Identity                                                          RegistrarPool
--------                                                          -------------
CN=Public Telephone,OU=RTC Special Accounts,DC=contoso,D... lync2010.contoso.local
CN=Linksys ATA,OU=RTC Special Accounts,DC=contoso,DC=local  lync2010.contoso.local
CN=HOTLINE,OU=RTC Special Accounts,DC=contoso,DC=local      lync2010.contoso.local
CN=Paging Speaker,OU=RTC Special Accounts,DC=contoso,DC=... lync2010.contoso.local

After:

PS > Get-CsAnalogDevice | ft Identity,RegistrarPool | out-string -Width 160

Identity                                                                         RegistrarPool
--------                                                                         -------------
CN=Public Telephone,OU=RTC Special Accounts,DC=contoso,DC=local            lync2010.contoso.local
CN=Linksys ATA,OU=RTC Special Accounts,DC=contoso,DC=local                 lync2010.contoso.local
CN=HOTLINE,OU=RTC Special Accounts,DC=contoso,DC=local                     lync2010.contoso.local
CN=Paging Speaker,OU=RTC Special Accounts,DC=contoso,DC=local              lync2010.contoso.local

Collections / Arrays

… but what if that doesn’t fix it?

It might be that the object you’re looking at is an array (a “collection”), and PowerShell is only showing the first few entries in that array, rather than the lot.

Here, the fix is to change the $FormatEnumerationLimit value. If you type it on its own into PowerShell the current value – probably 3 – will be returned. If you set a new value of -1, it’ll output ALL entries in your collection.

PS > $FormatEnumerationLimit
3
PS > $FormatEnumerationLimit=-1

Before:

PS > Get-CsCertificate

Issuer           : CN=contoso-CA, DC=contoso, DC=local
NotAfter         : 6/07/2013 5:09:37 PM
NotBefore        : 17/02/2012 7:04:52 PM
SerialNumber     : 1234567890ABCDEF
Subject          : CN=lync2010.contoso.local, OU=IT, O=contoso, L=Sydney, S=NSW, C=AU
AlternativeNames : {sip.contoso.net, lync2010.contoso.net, lync2010.contoso.local...}
Thumbprint       : 1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF
Use              : Default

After:

PS > Get-CsCertificate

Issuer           : CN=contoso-CA, DC=contoso, DC=local
NotAfter         : 6/07/2013 5:09:37 PM
NotBefore        : 17/02/2012 7:04:52 PM
SerialNumber     : 1234567890ABCDEF
Subject          : CN=lync2010.contoso.local, OU=IT, O=contoso, L=Sydney, S=NSW, C=AU
AlternativeNames : {sip.contoso.net, lync2010.contoso.net, lync2010.contoso.local, dialin.contoso.net, admin.contoso.net, meet
.contoso.net, LyncdiscoverInternal.contoso.net, lyncweb.contoso.net, Lyncdiscover.contoso.net}
Thumbprint       : 1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF
Use              : Default

 

Credit: This post is largely a re-write of this AWESOME Poshoholic gem.

Here’s a TechNet post with a few more formatting tips.

 

5 Comments

Leave a Reply

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

... and please just confirm for me that you're not a bot first: Time limit is exhausted. Please reload the CAPTCHA.