Solved

Need to get list of Mailboxes in an OU, Not Sub-OU's

Posted on 2014-11-19
2
2,858 Views
Last Modified: 2014-11-19
I'm struggling to write a Powershell command that will list all of the mailboxes in an OU, but leave out the mailboxes in sub-OU's.

I've tried:

get-mailbox -OrganizationalUnit "OU=Disabled Accounts,DC=domain,DC=com" | where {$_.distinguishedName -like "CN=*,OU=Disabled*"} | select-object name

Open in new window


get-mailbox -filter distinguishedName -like "CN=*,OU=Disabled Accounts,DC=domain,DC=COM"

Open in new window


get-mailbox -OrganizationalUnit "OU=Disabled Accounts,DC=Leavitt,DC=COM" -filter "distinguishedName -like 'CN=*,OU=Disabled Accounts,DC=domain,DC=COM'"

Open in new window


I'm just not getting this right.  Can someone help?

Thanks,

Dan
0
Comment
Question by:ddotson
2 Comments
 
LVL 16

Accepted Solution

by:
Rajitha Chimmani earned 500 total points
ID: 40453077
First get the canonical name of the organizational unit and try the following command

Get-Mailbox -Resultsize unlimited | where {$_.organizationalunit -eq "domain.com/Disabled Accounts"}
0
 

Author Comment

by:ddotson
ID: 40453128
That works perfectly.  Thank you!
0

Featured Post

Too many email signature updates to deal with?

Do you feel like you are taking up all of your time constantly visiting users’ desks to make changes to email signatures? Wish you could manage all signatures from one central location, easily design them and deploy them quickly to users? Well, there is an easy way!

Join & Write a Comment

Synchronize a new Active Directory domain with an existing Office 365 tenant
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
To show how to generate a certificate request 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 Servers >> Certificates…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

705 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

12 Experts available now in Live!

Get 1:1 Help Now