Hi,
You can get the OU names from the Name property and add the array to the listbox using AddRange().
$ListBox = New-Object System.Windows.Forms.ListBox
$ListBox.Location = New-Object System.Drawing.Point(10,50)
$ListBox.Height = 200
$ListBox.Width = 150
$ListBox.HorizontalScrollbar = $True
$OUName=(Get-ADOrganizationalUnit -LDAPFilter '(name=*)' -SearchBase '...' -SearchScope OneLevel).name
$Listbox.Items.AddRange($OUName)
#The List of OU should be listed as my choices in my listbox items.
$Appform.Controls.Add($ListBox)
Best Regards,
Ian Xue
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.