Displaying Array Members in Output

by Nov 20, 2018

When you output objects that have arrays in their properties, only 4 array elements are displayed, then an ellipsis truncates the rest:

 
PS C:\> Get-Process | Select-Object -Property Name, Threads -First 6

Name       Threads                    
----       -------                    
acrotray   {3160}                     
AERTSr64   {1952, 1968, 1972, 8188}   
AGSService {1980, 1988, 1992, 2000...}
armsvc     {1920, 1940, 1944, 7896}   
audiodg    {7436, 1460, 2192, 6784}   
ccSvcHst   {2584, 2644, 2656, 2400...}
 

To show more (or all) array elements, use the internal $FormatEnumerationLimit variable. It defaults to 4, but you can change it to the number of elements you want to display, or set it to -1 to show all elements:

 
PS C:\> $FormatEnumerationLimit = 1

PS C:\> Get-Process | Select-Object -Property Name, Threads -First 6

Name       Threads  
----       -------  
acrotray   {3160}   
AERTSr64   {1952...}
AGSService {1980...}
armsvc     {1920...}
audiodg    {7436...}
ccSvcHst   {2584...}



PS C:\> $FormatEnumerationLimit = 2

PS C:\> Get-Process | Select-Object -Property Name, Threads -First 6

Name       Threads        
----       -------        
acrotray   {3160}         
AERTSr64   {1952, 1968...}
AGSService {1980, 1988...}
armsvc     {1920, 1940...}
audiodg    {7436, 2192...}
ccSvcHst   {2584, 2644...}



PS C:\> $FormatEnumerationLimit = -1

PS C:\> Get-Process | Select-Object -Property Name, Threads -First 6

Name       Threads                                                              
----       -------                                                              
acrotray   {3160}                   
AERTSr64   {1952, 1968, 1972, 8188}                      
AGSService {1980, 1988, 1992, 2000, 2024, 7932}  
armsvc     {1920, 1940, 1944, 7896}
audiodg    {7436, 2192, 6784, 4540, 8040} 
ccSvcHst   {2584, 2644, 2656, 2400, 3080, 3120, 3124, 3128, 3132, 3136, 3140,...
 

When you set it to -1, the list is truncated only when the available space is consumed. To still see all values, explicitly use Format-Table and its –Wrap parameter:

 
PS C:\> Get-Process | Select-Object -Property Name, Threads -First 6 | Format-Table -Wrap

Name       Threads                                                              
----       -------                                                              
acrotray   {3160}                                                               
AERTSr64   {1952, 1968, 1972, 8188}                                             
AGSService {1980, 1988, 1992, 2000, 2024, 7932}                                 
armsvc     {1920, 1940, 1944, 7896}                                             
audiodg    {7436, 2192, 6784, 4540, 8040}                                       
ccSvcHst   {2584, 2644, 2656, 2400, 3080, 3120, 3124, 3128, 3132, 3136, 3140,   
           3144, 3232, 3240, 3248, 3260, 3268, 3288, 3304, 3344, 3492, 3552,    
           3556, 3568, 3572, 3576, 3580, 3596, 3600, 3604, 3612, 3616, 3708,    
           3712, 3716, 3724, 3732, 3736, 3760, 3764, 3768, 3776, 3780, 3796,    
           3800, 3804, 3816, 3820, 3824, 3828, 3832, 3844, 3888, 3892, 4232,    
           5084, 5088, 3112, 7100, 7016, 480, 3020, 3044, 4744, 7148, 1828,     
           6476, 6516, 6524, 7160, 6652, 7000, 964, 6028, 4644, 4828, 6664,     
           7892, 5820, 8180, 4940, 5956, 7684, 7156}                            



PS C:\> 
 

Twitter This Tip! ReTweet this Tip!