Truncated Output in form

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 4 months and 3 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
dwpeter
Posts: 2
Last visit: Mon Jun 10, 2024 1:22 pm

Truncated Output in form

Post by dwpeter »

Hi, All.

I have a PS form I'm developing. If I run the script/form, and do something like get the system services, everything is returned just fine. If I package up the script as a WinForm under PS version 7.3.x, then run the same call to get the list of services from the same system, the output is truncated (in the attached images there is a horizontal scrollbar to see all the output for the non-truncated lines, but I think you'll get the idea). Here is an example:

Before packaging:
Image

After packaging:
Image

Is there a way, after I've packaged up the script as a WinForm in PS Studio 24, to allow for longer output per line? Is this some sort of screen buffer sizing that needs to be added to me script, or the package settings?

Thanks,
D.
Attachments
ServicesOutput2.jpg
ServicesOutput2.jpg (20.84 KiB) Viewed 1762 times
ServicesOutput1.jpg
ServicesOutput1.jpg (18.15 KiB) Viewed 1762 times
User avatar
Alexander Riedel
Posts: 8575
Last visit: Sat Nov 02, 2024 12:15 pm
Answers: 23
Been upvoted: 42 times

Re: Truncated Output in form

Post by Alexander Riedel »

PowerShell's automatic formatting is based on an assumed or actual console width. When packaged, there is no console object, so it assumes a default width of 80 characters (I think).
Always make sure to run output like that through Format-Table with the desired parameters yourself.
Alexander Riedel
SAPIEN Technologies, Inc.
dwpeter
Posts: 2
Last visit: Mon Jun 10, 2024 1:22 pm

Re: Truncated Output in form

Post by dwpeter »

I'm slapping myself in the forehead now. I knew that, ignored it, then posted the topic. It's all fixed by adding "* | Out-String -width 175" to the output.

Well... thanks for the nudge in the right direction.

D
This topic is 4 months and 3 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked