Page 1 of 1

Array and Richtextbox

Posted: Tue Sep 18, 2018 4:38 am
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

Re: Array and Richtextbox

Posted: Tue Sep 18, 2018 6:02 am
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.

Re: Array and Richtextbox

Posted: Tue Sep 18, 2018 6:35 am
by ALD Automotive
Could you give me advice?
What can i use instead?

Re: Array and Richtextbox

Posted: Tue Sep 18, 2018 10:26 am
by jvierra
Remove Format-Table. It is not necessary.