How Can We Help?
< Back
You are here:
Print

Table vs List

When you are using the Select-Object cmdlet, you might have noticed that the results are sometimes displayed as a table and sometimes as a list. It is handy to understand what the logic behind this is.

The basic rule is quite simple, if you display less than 5 properties, the PowerShell output engine will display the results as a table.

Results in

When there are 5 or more properties, the output will be displayed as a list.

Another rule worth knowing, is that the first Select-Object output determines how the other Select-Object outputs in your script will be displayed.

The 1st one shows 5 properties, so it will be displayed as a list. But also the 2nd one, which only displays 3 properties, will also be displayed as a list.

When you do the reverse, you will notice that the output is in table format, but the 5th property will not be shown.

One way to avoid that the 1st Select-Object determines how the others in your script behave, is to use the Out-Default cmdlet.
This cmdlet kind of “resets” the output, and so the 5-properties rules will be applied as if it was the first Select-Object.

Leave a Reply

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

*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Table of Contents