Array and Richtextbox

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 5 years and 6 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
ALD Automotive
Posts: 11
Last visit: Thu Jun 01, 2023 4:52 am

Array and Richtextbox

Post by ALD Automotive »

Hello,
Please help me with Array and Richtextbox

Code: Select all

$user1 = $tab2_compare_group1.Text
$user2 = $tab2_compare_group2.Text
			
$group1 = Get-ADUser $user1 -Properties * | Select-Object -ExpandProperty memberof | ForEach-Object { (($_.split(","))[0]).substring(3) } | Sort-Object -CaseSensitive
$group2 = Get-ADUser $user2 -Properties * | Select-Object -ExpandProperty memberof | ForEach-Object { (($_.split(","))[0]).substring(3) } | Sort-Object -CaseSensitive
			
$Object = New-Object System.Management.Automation.PSObject
$result = $Object | Select-Object  @{ name = "Have $(Get-ADUser $user2 | Select-Object -ExpandProperty name), but don't have $(Get-ADUser $user1 | Select-Object -ExpandProperty name)          "; Expression = { (Compare-Object $group1 $group2 | Where-Object { $_.SideIndicator -eq "=>" }).InputObject | out-string } }, @{ name = "Have $(Get-ADUser $user1 | Select-Object -ExpandProperty name),but don't have $(Get-ADUser $user2 | Select-Object -ExpandProperty name)"; Expression = { (Compare-Object $group1 $group2 | Where-Object { $_.SideIndicator -eq "<=" }).InputObject | out-string } } |ft -wrap
$textboxDisplay.Text= $result
As result i receive: "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData"
But i want to see 2 columns with my data at textbox(please see attachment)
And if i add "|out-string" i resecive all data in 1 row
Attachments
SAPIENS Result.jpg
SAPIENS Result.jpg (42.3 KiB) Viewed 1561 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Array and Richtextbox

Post by jvierra »

You cannot use the output to "Format-Table" to output plain text to a textbox or a file. It is designed to output to the console.
User avatar
ALD Automotive
Posts: 11
Last visit: Thu Jun 01, 2023 4:52 am

Re: Array and Richtextbox

Post by ALD Automotive »

Could you give me advice?
What can i use instead?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Array and Richtextbox

Post by jvierra »

Remove Format-Table. It is not necessary.
This topic is 5 years and 6 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