Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Setting width of output

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 11-10-2006   #1 (permalink)
Peter Thornqvist
Guest


 

Setting width of output

Hi all, I am wondering if there is some command/method to change the width
of the output from powershell? I've noticed that when called from another
process, the display width is truncated to 80 chars and I would like to
change this. Any ideas on how to do it?

--
Regards, Peter



My System SpecsSystem Spec
Old 11-10-2006   #2 (permalink)
klumsy@xtra.co.nz
Guest


 

Re: Setting width of output

i believe in powershell.exe its going to be the width on your console
screen which you can set in windows the same as you do for cmd.exe (i
think it can be done visually , right click properties, as well as with
cmdline options when starting cmd.exe or powershell.exe

in powershell analyzer, i have a fulldown that allows you to determine
the width of the console on the fly.

My System SpecsSystem Spec
Old 11-11-2006   #3 (permalink)
Peter Thornqvist
Guest


 

Re: Setting width of output

Thanks for the reply. Unfortunately, I haven't been able to find a command
parameter that changes the output buffer width and changing the properties
for the powershell or cmd window does nothing AFAICS. Do you know the cmd
line parameter required or do you know where I can find more info about
setting the output width?

--
Regards, Peter

<klumsy@xtra.co.nz> skrev i meddelandet
news:1163206271.398933.21330@k70g2000cwa.googlegroups.com...
>i believe in powershell.exe its going to be the width on your console
> screen which you can set in windows the same as you do for cmd.exe (i
> think it can be done visually , right click properties, as well as with
> cmdline options when starting cmd.exe or powershell.exe
>
> in powershell analyzer, i have a fulldown that allows you to determine
> the width of the console on the fly.
>



My System SpecsSystem Spec
Old 11-11-2006   #4 (permalink)
Alex K. Angelopoulos [MVP]
Guest


 

Re: Setting width of output

Can you provide an example of what you are doing with calling PS and saving
the output? There are several ways to handle this, including setting width
in Out-File, using a different output format, and directly exporting to a
specific file type either using export-csv or a custom data exporter.

"Peter Thornqvist" <peter.tornqvist@gmail.com> wrote in message
news:uj6spQZBHHA.5068@TK2MSFTNGP02.phx.gbl...
> Thanks for the reply. Unfortunately, I haven't been able to find a command
> parameter that changes the output buffer width and changing the properties
> for the powershell or cmd window does nothing AFAICS. Do you know the cmd
> line parameter required or do you know where I can find more info about
> setting the output width?
>
> --
> Regards, Peter
>
> <klumsy@xtra.co.nz> skrev i meddelandet
> news:1163206271.398933.21330@k70g2000cwa.googlegroups.com...
>>i believe in powershell.exe its going to be the width on your console
>> screen which you can set in windows the same as you do for cmd.exe (i
>> think it can be done visually , right click properties, as well as with
>> cmdline options when starting cmd.exe or powershell.exe
>>
>> in powershell analyzer, i have a fulldown that allows you to determine
>> the width of the console on the fly.
>>

>
>



My System SpecsSystem Spec
Old 11-11-2006   #5 (permalink)
Andrew Watt [MVP]
Guest


 

Re: Setting width of output

Peter,

I am not certain if this is what you are interested in or not.

Try this and report back if it does what you need or not.

$bufferSize = new-object System.Management.Automation.Host.Size 120,60
$host.UI.RawUI.WindowSize = $bufferSize

Andrew Watt MVP

On Sat, 11 Nov 2006 14:20:30 +0100, "Peter Thornqvist"
<peter.tornqvist@gmail.com> wrote:

>Thanks for the reply. Unfortunately, I haven't been able to find a command
>parameter that changes the output buffer width and changing the properties
>for the powershell or cmd window does nothing AFAICS. Do you know the cmd
>line parameter required or do you know where I can find more info about
>setting the output width?

My System SpecsSystem Spec
Old 11-11-2006   #6 (permalink)
Peter Thornqvist
Guest


 

Re: Setting width of output

> $bufferSize = new-object System.Management.Automation.Host.Size 120,60
> $host.UI.RawUI.WindowSize = $bufferSize


If I add the buffer size to the command, it does work very well (without
buffer size I get an error that windowsize cannot be larger than
buffersize):

$bufferSize = new-object System.Management.Automation.Host.Size 160,80
$host.UI.RawUI.BufferSize = $bufferSize
$host.UI.RawUI.WindowSize = $bufferSize

This lead me to try to set the buffer size in cmd.exe as well as PowerShell,
without results.

*Then it hit me*. I had been changing the PowerShell shortcut on my Start
menu all the time. Thi, of course, isn't used when FB calls CreatePRocess.
So, I tried starting powershell directly from the powershell folder and
change the settings there and BINGO! That did it!

Still, if anyone knows about a command that I can send to PowerShell to
change display width, I'd appreciate it a lot.

--
Regards, Peter


My System SpecsSystem Spec
Old 11-11-2006   #7 (permalink)
Peter Thornqvist
Guest


 

Re: Setting width of output

> Can you provide an example of what you are doing with calling PS and
> saving
> the output? There are several ways to handle this, including setting width
> in Out-File, using a different output format, and directly exporting to a
> specific file type either using export-csv or a custom data exporter.


OK, let's see if I can explain this in more detail:

I am writing an action for an automation tool (FinalBuilder) where the user
can execute a PowerShell command or script. When the action is run, the
output in FB's log window is truncated to 80 chars.
I've asked the FB people and they say that they don't truncate, so my guess
it's PS.

I've tried various commands to try to expand the line width and the best
I've come up with is to pipe through Out-String specifying -stream -width
200 although the output is far from optimal (the extra line wraps is due to
FB wrapping at 80 chars, not PS).

The optimal solution for me is if there was a setting I could apply
globally to the PowerShell window without having to append it to the
command-line. If this was possible, I could include a property in the action
to change the output width (much as is done in PowerShell Analyzer).

I'm pretty sure FB uses CreateProcess to call PS, so that might play into it
as well.

I tried to attach some screenshots, but the article was too large, so you'll
just have to picture it internally

Any hints/ideas appreciated

--
Regards, Peter



My System SpecsSystem Spec
Old 11-18-2006   #8 (permalink)
Alex K. Angelopoulos [MVP]
Guest


 

Re: Setting width of output

I haven't forgotten this; I was waiting for an opportunity to install FB
evaluation and check some things. Still need to finish that, but I already
have some comments inline...

"Peter Thornqvist" <peter.tornqvist@gmail.com> wrote in message
news:%23spJ9DbBHHA.4864@TK2MSFTNGP04.phx.gbl...
>> Can you provide an example of what you are doing with calling PS and
>> saving the output? There are several ways to handle this...


> I am writing an action for an automation tool (FinalBuilder) where the
> user
> can execute a PowerShell command or script. When the action is run, the
> output in FB's log window is truncated to 80 chars.
> I've asked the FB people and they say that they don't truncate, so my
> guess
> it's PS.


Sort of. I suspect FB is generating a default console process and the way in
which things get retrieved is that the host text stream is grabbed - which
is already passed through the formatter. In any case, the display is always
going to be affected by the selection of items to display.

At the moment, I suspect your best bet is to use '-outputformat xml' in the
command; for example:
powershell -OutputFormat xml -command "& {get-eventlog -logname
security}"
If you test this from a cmd.exe command prompt and redirect to a file,
you'll see that data is NOT truncated.


> I've tried various commands to try to expand the line width and the best
> I've come up with is to pipe through Out-String specifying -stream -width
> 200 although the output is far from optimal (the extra line wraps is due
> to FB wrapping at 80 chars, not PS).
>
> The optimal solution for me is if there was a setting I could apply
> globally to the PowerShell window without having to append it to the
> command-line. If this was possible, I could include a property in the
> action
> to change the output width (much as is done in PowerShell Analyzer).
>
> I'm pretty sure FB uses CreateProcess to call PS, so that might play into
> it
> as well.
>
> I tried to attach some screenshots, but the article was too large, so
> you'll just have to picture it internally
>
> Any hints/ideas appreciated
>
> --
> Regards, Peter
>
>
>



My System SpecsSystem Spec
Old 11-18-2006   #9 (permalink)
Peter Thornqvist
Guest


 

Re: Setting width of output

Cool, thanks. BTW, you can get the PS action from the Community Download on
the FB page. You can see how the output looks when running a PS command from
within FB.

Thanks again

--
Regards, Peter

"Alex K. Angelopoulos [MVP]" <aka@online.mvps.org> skrev i meddelandet
news:OLtIb8xCHHA.4808@TK2MSFTNGP03.phx.gbl...
>I haven't forgotten this; I was waiting for an opportunity to install FB
>evaluation and check some things. Still need to finish that, but I already
>have some comments inline...
>
> "Peter Thornqvist" <peter.tornqvist@gmail.com> wrote in message
> news:%23spJ9DbBHHA.4864@TK2MSFTNGP04.phx.gbl...
>>> Can you provide an example of what you are doing with calling PS and
>>> saving the output? There are several ways to handle this...

>
>> I am writing an action for an automation tool (FinalBuilder) where the
>> user
>> can execute a PowerShell command or script. When the action is run, the
>> output in FB's log window is truncated to 80 chars.
>> I've asked the FB people and they say that they don't truncate, so my
>> guess
>> it's PS.

>
> Sort of. I suspect FB is generating a default console process and the way
> in which things get retrieved is that the host text stream is grabbed -
> which is already passed through the formatter. In any case, the display is
> always going to be affected by the selection of items to display.
>
> At the moment, I suspect your best bet is to use '-outputformat xml' in
> the command; for example:
> powershell -OutputFormat xml -command "& {get-eventlog -logname
> security}"
> If you test this from a cmd.exe command prompt and redirect to a file,
> you'll see that data is NOT truncated.
>
>
>> I've tried various commands to try to expand the line width and the best
>> I've come up with is to pipe through Out-String specifying -stream -width
>> 200 although the output is far from optimal (the extra line wraps is due
>> to FB wrapping at 80 chars, not PS).
>>
>> The optimal solution for me is if there was a setting I could apply
>> globally to the PowerShell window without having to append it to the
>> command-line. If this was possible, I could include a property in the
>> action
>> to change the output width (much as is done in PowerShell Analyzer).
>>
>> I'm pretty sure FB uses CreateProcess to call PS, so that might play into
>> it
>> as well.
>>
>> I tried to attach some screenshots, but the article was too large, so
>> you'll just have to picture it internally
>>
>> Any hints/ideas appreciated
>>
>> --
>> Regards, Peter
>>
>>
>>

>
>



My System SpecsSystem Spec
Old 02-06-2007   #10 (permalink)
Peter Monadjemi
Guest


 

Re: Setting width of output

Peter Thornqvist schrieb:
> Hi all, I am wondering if there is some command/method to change the width
> of the output from powershell? I've noticed that when called from another
> process, the display width is truncated to 80 chars and I would like to
> change this. Any ideas on how to do it?
>

What about

mode con cols=132?

Peter

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting Output Cacheability Programmatically is Not Working - In Custom Handler Jordan S. .NET General 0 05-22-2008 09:34 PM
Setting per Application Sound Output, or Per Sound Type Outputs... Michichael Vista General 0 09-24-2007 01:40 AM
Scrollbar width Val Vista General 3 07-12-2007 01:10 AM
Validation needed: Tabular output throws OutofMemoryException errors with Out-File -Width 0x7fffffff Alex K. Angelopoulos [MVP] PowerShell 5 06-28-2006 06:49 AM
OrthographicCamera.Width and translation 2D to 3D Erno Avalon 2 01-31-2006 07:00 AM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51