Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Powershell script : Get-ADOrganizationalUnit in windows list box

Posted on 2016-09-09
2
Medium Priority
?
415 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 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

Looking for the Wi-Fi vendor that's right for you?

We know how difficult it can be to evaluate Wi-Fi vendors, so we created this helpful Wi-Fi Buyer's Guide to help you find the Wi-Fi vendor that's right for your business! Download the guide and get started on our checklist today!

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

722 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