Active Directory
A set of directory-based technologies included in Windows Server.
6,856 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
$OuListBox = New-Object System.Windows.Forms.ListBox
$OuListBox.Location = New-Object System.Drawing.Point(10,50)
$OuListBox.Height = 200
$OuListBox.Width = 150
$OuListBox.HorizontalScrollbar = $True
$OuListBox.Items.Add($OUName) #it should list the items in my listbox
$Appform.Controls.Add($OuListBox)
Nevermind, found the solution to my question by adding foreach in my pipeline.
Get-ADOrganizationalUnit -LDAPFilter '(name=*)' -SearchBase 'OU=OUname,DC=DCname,DC=DClocal' -SearchScope OneLevel | foreach{[void]$OuListBox.Items.Add($_.name)}