GUI and Format List - Assistance

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.
Locked
User avatar
Reddrgn2
Posts: 8
Joined: Wed May 23, 2018 6:13 am

GUI and Format List - Assistance

Post by Reddrgn2 » Thu Jun 27, 2019 12:35 pm

Hi, I am creating small form to get some basic AD info based of emp #. The building of the form and the coding part is kind of the easy part. The issue I am having is the format-list part. I do not like how it looks on the form after entering emp # and clicking find button, see below for screen shot.

Image

Code: Select all

$label2.Text = Get-ADUser -Filter "EmployeeID -eq '<emp id number>'" -Properties Name, SAMAccountName, Enabled, description, title, SID, UserPrincipalName	| Format-List -Property Name, SAMAccountName, Enabled, Description, Title, UserPrincipalName, SID | Out-String
I am not sure why the coding is green colored.

I adjusted the script for this form, you would normally enter emp # in text box then click find. Clicking find does the magic and runs the script to populate the label2 textbox.

Sadly it took 20mins to build form and do the scripting, about over an hour of trying to tinker with the format-list part and end result before creating this form. I know it will take 2 mins for someone to assist me, :)

User avatar
davidc
Posts: 5913
Joined: Thu Aug 18, 2011 4:56 am

Re: GUI and Format List - Assistance

Post by davidc » Thu Jun 27, 2019 12:56 pm

You will need to use a fixed-point font, so that the text aligns correctly.

1. You can set the TextBox's Font property using the Properties panel. You can use the Courier New font.

2. Or select the TextBox in the designer and press [Ctrl + L] to apply a property set. Select Apply Console Font from list and it will change the font for all the selected controls.

3. You can also use one of preset form templates that contain a TextBox. They come preconfigured with a fixed-point font.
David
SAPIEN Technologies, Inc.

User avatar
Reddrgn2
Posts: 8
Joined: Wed May 23, 2018 6:13 am

Re: GUI and Format List - Assistance

Post by Reddrgn2 » Thu Jun 27, 2019 1:21 pm

Thank you, you solved it. :) :)

Locked