Page 1 of 1

Problem when program is run from EXE vs IDE

Posted: Wed Jun 12, 2019 9:10 am
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.  
  3.         $copyMe = $GROUPS | FT | Out-String
  4.  
  5.         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. ----                                           -----                          
  4.  
  5. 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!

Re: Problem when program is run from EXE vs IDE

Posted: Wed Jun 12, 2019 9:41 am
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.

Re: Problem when program is run from EXE vs IDE

Posted: Fri Jun 14, 2019 9:51 am
by kdwisdom
That resolved my issue, thanks!