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 SUBSCRIPTION NUMBERS, LICENSE 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.
kdwisdom
Posts: 7
Joined: Mon Apr 22, 2019 11:04 pm

Problem when program is run from EXE vs IDE

Post by kdwisdom » Wed Jun 12, 2019 9:10 am

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. ***

Code: Select all

$GROUPS = Get-ADPrincipalGroupMembership $adUser | select name, @{ name = "Desc1"; expression = { (get-adgroup -filter { name -eq $_.name } -Properties description).description } } | sort name | ft -AutoSize
$copyMe = $GROUPS | FT | Out-String
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:

Code: Select all

name Desc1
---- -----
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: 7049
Joined: Tue May 29, 2007 4:43 pm

Re: Problem when program is run from EXE vs IDE

Post by Alexander Riedel » Wed Jun 12, 2019 9:41 am

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: 7
Joined: Mon Apr 22, 2019 11:04 pm

Re: Problem when program is run from EXE vs IDE

Post by kdwisdom » Fri Jun 14, 2019 9:51 am

That resolved my issue, thanks!