Solved

powershell getting user in sub-OU's

Posted on 2016-07-21
2
10 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

Wish Marketing would stop bothering you?

Is your marketing department constantly asking for new email signature updates? Are they requesting a different design for every department? Do they need yet another banner added? Don’t let it get you down! There is an easy way to manage all of these requests...

Join & Write a Comment

Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
In this video we show how to create a User Mailbox 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 Recipients >> Mailb…
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…

706 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

19 Experts available now in Live!

Get 1:1 Help Now