Solved

Powershell script : Get-ADOrganizationalUnit in windows list box

Posted on 2016-09-09
2
166 Views
Last Modified: 2016-09-09
Dear All,

I have this structure in my AD

DC=lan
            DC=MyDomain
                                      OU=Root
                                                      OU=ou1
                                                              OU=ou11
                                                              OU=ou12
                                                      OU=ou2
                                                              OU=ou21
                                                              OU=ou22
                                                      OU=ou3
                                                              OU=ou31
                                                              OU=ou32

I would like to use the cmdlet Get-ADOrganizationalUnit to display ou1, ou2 and ou3 only (not the sub OU) in a windows list box in order to select them for next action.
I can't see how to achieve this?

Thks

JJC
0
Comment
Question by:celmajj
2 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 41791457
You can use Get-ADOrganizationalUnit with -SearchScope parameter..
Import-Module ActiveDirectory
Get-ADOrganizationalUnit -F * -SearchScope OneLevel -SearchBase "OU=Root,DC=MyDomain,DC=lan" | Select -exp Distin*

Open in new window

For selecting Items From a List Box, refer following article..
https://technet.microsoft.com/en-us/library/ff730949.aspx
0
 

Author Comment

by:celmajj
ID: 41791499
good.

Thks you
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question