Question : How can I change the display lenght in PowerShell?

Hi,

Sometime when I execute cmd like get-mailbox to list info with OU, the OU did not show completely. It finish by "..."

How can I change the display lenght in PowerShell?

Answer : How can I change the display lenght in PowerShell?

You have three options. Let's see the example with this command:

get-mailbox | format-table name, primarysmtpaddress, distinguishedname

Probaly the distinguishedname column does not fit into the screen.

First you can do is use the -wrap switch for format-table:

get-mailbox | ft name, primarysmtpaddress, distinguishedname -wrap

This will wrap the all the 'cells' of information that does not fit into its column. The problem with that is - as in this example - other columns have more space unneccessarily. So the second option is to overwrite the default columns widths:

get-mailbox | ft name, primarysmtpaddress, @{n="distinguishedname"; e={$_.distinguishedname}; w=70}

With this hashtable definition I set a new coulmn that has the same name as the original one (n=...), even the data is the same ({e=...}) but has a new width (w=...).

The third option is to output the result to the gridview:

Get-Mailbox | Select-Object name, primarysmtpaddress, distinguishedname | out-gridview

In this new grid window you can adjust the columnwidth by the mouse.
Random Solutions  
 
programming4us programming4us