Problem when program is run from EXE vs IDE

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

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 years and 9 months 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.
kdwisdom
Posts: 25
Last visit: Fri Jan 26, 2024 10:39 am

Problem when program is run from EXE vs IDE

Post by kdwisdom »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product: PowerShell Studio 2019 (64 Bit)
Build: v5.6.164
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.17134.0

*** Please add details and screenshots as needed below. ***
  1.         $GROUPS = Get-ADPrincipalGroupMembership $adUser | select name, @{ name = "Desc1"; expression = { (get-adgroup -filter { name -eq $_.name } -Properties description).description } } | sort name | ft -AutoSize
  2.         $copyMe = $GROUPS | FT | Out-String
  3.         Set-Clipboard -Value $copyMe
I have a form in my program that will copy all AD groups with their descriptions to the clipboard.

When I launch this from the IDE, it copies perfectly. Has the group names and group descriptions like this:
  1. name                                           Desc1                          
  2. ----                                           -----                          
  3. Domain Users                                   All domain users  
When I launch it from the EXE I built, it does this:
IdentityAccessManagement FA-RW \\fileserver\IT FileShare\W...

See the "..." -- It truncates the description.

Why would it do this from the EXE (I freshly built it and ran the new EXE build) but not when I press "Run" in the IDE?

Thanks for your help!
User avatar
Alexander Riedel
Posts: 8473
Last visit: Tue Mar 19, 2024 1:15 am
Answers: 19
Been upvoted: 37 times

Re: Problem when program is run from EXE vs IDE

Post by Alexander Riedel »

Format-table is a tricky cmdlet. It uses the console width to determine sizes. Since the output in the IDE is piped into a window we artificially set that to "very wide" (I do not know the exact width now).
In an exe, assuming it is packaged as a console app, it uses the console width. In an exe packaged as a form, well, there is no console, so it uses the default 80 I would guess.
You can try something like described here:
https://www.jaapbrasser.com/quicktip-ch ... nd-buffer/

But generally I would just write code to format the table to your specifications rather than hoping to coax PowerShell to do it for you.
Alexander Riedel
SAPIEN Technologies, Inc.
kdwisdom
Posts: 25
Last visit: Fri Jan 26, 2024 10:39 am

Re: Problem when program is run from EXE vs IDE

Post by kdwisdom »

That resolved my issue, thanks!
This topic is 4 years and 9 months 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.