How to show Format-table output into label control

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 6 years and 11 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.
Locked
User avatar
mrosema
Posts: 7
Last visit: Mon Apr 02, 2018 9:35 am

How to show Format-table output into label control

Post by mrosema »

I am new with Powershell Studio and now I am trying to show the following script into a label:
$AllUsers
=
Get-ADUser
-Filter
*
-properties
PasswordExpired, PasswordLastSet, PasswordNeverExpires
|


Format-Table
Name, PasswordExpired, PasswordLastSet, PasswordNeverExpires
-AutoSize
-Wrap
|
Out-String
And the output isn't aligned, when I run the same script into powershell it gets aligned perfectly. What am I doing wrong?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How to show Format-table output into label control

Post by jvierra »

You need to use a fixed font.
User avatar
mrosema
Posts: 7
Last visit: Mon Apr 02, 2018 9:35 am

Re: How to show Format-table output into label control

Post by mrosema »

I have set the same font type and size for both the label as the form, but still it doesn't align. Is this what you mean by fixed font?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How to show Format-table output into label control

Post by jvierra »

User avatar
mrosema
Posts: 7
Last visit: Mon Apr 02, 2018 9:35 am

Re: How to show Format-table output into label control

Post by mrosema »

That fixed the problem, thank you so much for the good help.
This topic is 6 years and 11 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.
Locked