List Multiple Attributes within a Powershell Form

This topic contains 2 replies, has 2 voices, and was last updated by  Daniel Geromini 2 years, 8 months ago.

  • Author
  • #31069

    Daniel Geromini

    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!


  • #31070

    Curtis Smith

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

    For example instead of:



    $reportBox.Items.Add("$($ $($_.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)")}
  • #31074

    Daniel Geromini

    That worked great! Thank you!

You must be logged in to reply to this topic.