Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How can I change the display lenght in PowerShell?

Posted on 2010-08-21
7
Medium Priority
?
1,579 Views
Last Modified: 2012-05-10
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?
0
Comment
Question by:SAM2009
7 Comments
 
LVL 6

Assisted Solution

by:DewFreak
DewFreak earned 200 total points
ID: 33491894
0
 
LVL 13

Accepted Solution

by:
soostibi earned 1200 total points
ID: 33492488
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.
0
 
LVL 12

Assisted Solution

by:Mahmoud Sabry
Mahmoud Sabry earned 400 total points
ID: 33493059
find the below steps 1, then 2

1.png
2.png
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
LVL 12

Assisted Solution

by:Mahmoud Sabry
Mahmoud Sabry earned 400 total points
ID: 33493166
you can use the command

Start-Transcript c:\users.txt

after you run the Cmdlet, this will copy the output to the specified path, and you then can copy and paste files into excel
0
 
LVL 1

Author Comment

by:SAM2009
ID: 33494084
Thank you guys for all your suggestions. I will try on Monday and let you know.

Also is  there a way to export the result directly to Excel?
0
 
LVL 71

Assisted Solution

by:Chris Dent
Chris Dent earned 200 total points
ID: 33500485

Very easily:

Get-Mailbox | Export-Csv "SomeFile.csv"

You'll notice a type identifier in the first row (prefixed with #). You can drop that by using -NoTypeInformation:

Get-Mailbox | Export-Csv "SomeFile.csv" -NoTypeInformation

Chris
0
 
LVL 1

Author Closing Comment

by:SAM2009
ID: 33507537
Cool! Thank you very much everybody.

The  combination of width parameter, display properties and export file option let me do what I need.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Screencast - Getting to Know the Pipeline

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question