Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 665
  • Last Modified:

How to search for ad property and put result in a listbox via powershell?

I'm using the following command:
Get-QADUser -IncludedProperties extensionAttribute1 -SearchRoot someou | ft extensionAttribute1

This returns the value of this property for every user in that ou. I want the value to be added to a listbox but only once for each value and use this in the script found here(http://technet.microsoft.com/en-us/library/ff730949.aspx)
 e.g. the above script returns 5 times "something1" and 5 times "something2". I want the listbox containing just 1 time "something1" and 1 time "something2" so I can use this in the selectbox([void] $objListBox.Items.Add("something1").

How can I achieve this?

Thnx Remco
0
pr0fier
Asked:
pr0fier
1 Solution
 
pr0fierAuthor Commented:
solved it by using the following commands:

      $arrTitle = Get-QADUser -IncludedProperties extensionAttribute1 -SearchRoot [root] | foreach {$_.extensionAttribute1} | select -uniq
      
      foreach ($arr in $arrTitle){
      Write-Host $arr
      [void] $objListbox.Items.Add("$arr")            
      }
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Tackle projects and never again get stuck behind a technical roadblock.
Join Now