List Multiple Attributes within a Powershell Form

I am trying to list all user accounts with the “info” attribute equal to archived* to a Powershell Form listbox window named $reportBox. I have the cmd below:

get-aduser -LDAPFilter “(info=archived*)” -SearchBase “OU=Test,DC=Domain,DC=Local” -Properties info | select info,distinguishedname | ForEach-Object {[void] $reportBox.Items.Add($_)}

This displays the following text in the listbox:

@{info=Archived; distinguishedname=CN=Test User,OU=Test,DC=Domain,DC=Local}
@{info=Archived; distinguishedname=CN=Test1 User,OU=Test,DC=Domain,DC=Local}
@{info=Archived; distinguishedname=CN=Test2 User,OU=Test,DC=Domain,DC=Local}

I want it to look like:

Archived CN=Test User,OU=Test,DC=Domain,DC=Local
Archived CN=Test1 User,OU=Test,DC=Domain,DC=Local
Archived CN=Test2 User,OU=Test,DC=Domain,DC=Local

What modifications do I need to make to the command so I get this output in a Powershell Form listbox?

Thanks for any help!


You need to just make a string out of the values you want in your Add method.

For example instead of:



$reportBox.Items.Add(“$($.info) $($.distinguishedname)”)

get-aduser -LDAPFilter "(info=archived*)" -SearchBase "OU=Test,DC=Domain,DC=Local" -Properties info |
 select info,distinguishedname |
  ForEach-Object {[void] $reportBox.Items.Add("$($ $($_.distinguishedname)")}

That worked great! Thank you!