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

x
?
Solved

powershell getting user in sub-OU's

Posted on 2016-07-21
2
Medium Priority
?
21 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
[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 16

Accepted Solution

by:
FOX earned 2000 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:Britt Thompson
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A couple of months ago we ran into an issue that necessitated re-creating our Edge Subscriptions. However, when we attempted to execute the command: New-EdgeSubscription -filename C:\NewEdgeSub_01.xml we received an error indicating that the LDAP se…
Know the reasons and solutions to move/import EDB to New Exchange Server. Also, find out how to recover an Exchange .edb file and to restore the file back.
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

730 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