Solved

powershell getting user in sub-OU's

Posted on 2016-07-21
2
12 Views
Last Modified: 2016-07-22
I have a powershell script that goes and gets

Import-Csv c:\importfile.csv | ForEach-Object {
    Get-Mailbox $_.'User-email' | where {$_.organizationalunit -LIKE "Microsoft.com/User Accounts/"}

Open in new window



presently I get users only in the user accounts OU. What I would like to do is grab any user in a sub ou under User accounts.
0
Comment
Question by:techdrive
2 Comments
 
LVL 16

Accepted Solution

by:
FOX earned 500 total points
ID: 41722984
The below will get all users in that OU and the sub OUs

Get-ADuser -filter * -searchbase "ou=User Accounts,dc=microsoft,dc=com"
0
 
LVL 30

Expert Comment

by:renazonse
ID: 41723001
You can add in an additional -NE "Microsoft.com/Accounts" and use a * after the last / in your -like statement
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
A brief introduction to what I consider to be the best editor for PowerShell.
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…

911 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now