Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Method of obtaining only users with mailboxes, per OU

Posted on 2014-01-10
5
Medium Priority
?
379 Views
Last Modified: 2014-02-13
Hi,

I hope someone can help and I guess there might be an easy answer to this. I am looking to get a list of users, but only those with mailboxes, and I would like it per OU. In EMC there is a column for OU but annoyingly, this doesn't appear in the list of filters. I'm sure there will be a simple enough way to do this via Powershell, I'm just not sure how!

Thanks in advance...
0
Comment
Question by:ishamsi
[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
  • 2
5 Comments
 
LVL 25

Expert Comment

by:Zephyr ICT
ID: 39770726
In Powershell you can use something like this, but might be too general?

get-mailbox -OrganizationalUnit 'OU=finances,OU=Physical,OU=Accounts,DC=domain,DC=com'

Open in new window

0
 

Author Comment

by:ishamsi
ID: 39770934
Thanks. Yeah, that does work, but I need it to be formatted a bit more nicely and, since there are a lot of OU's, it would be nice if one command could output all of them, but separated by OU. Any ideas?
0
 
LVL 25

Assisted Solution

by:Zephyr ICT
Zephyr ICT earned 1000 total points
ID: 39771087
Something like this might work:

$AllMailboxes = @() 
 foreach ($ou in Get-OrganizationalUnit) 
 { 
  $AllMailboxes += Get-Mailbox -OrganizationalUnit $ou.DistinguishedName -ResultSize Unlimited |Select-Object OrganizationalUnit,DisplayName,PrimarySmtpAddress, @{Name="EmailAddresses";Expression={$_.EmailAddresses |Where-Object ` 
{$_.PrefixString -ceq "smtp"} | ForEach-Object {$_.SmtpAddress}}} 
 } 
 $AllMailboxes |Export-Csv c:\test.csv -NoTypeInformation  

Open in new window


Sorry, not a lot of time to test out the script, but it should do the job.
0
 
LVL 43

Accepted Solution

by:
Adam Brown earned 1000 total points
ID: 39772131
get-mailbox | select name,primarysmtpaddress,organizationalunit |sort-object organizationalunit | export-csv <file path>

Open in new window


Easiest way to do it right there. You can cut the |export-csv part out if you like to just display it and not output to CSV file.
0
 

Author Closing Comment

by:ishamsi
ID: 39855775
Hi,

Thanks very much for these and apologies about the delay in my response. Both these commands gave me what I needed so I'll split the points. Thanks again.
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

As much as Microsoft wants to kill off PST file support, just as they tried to do with public folders, there are still times when it is useful or downright necessary to export Exchange mailboxes to PST files. Thankfully, it is still possible to e…
If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
how to add IIS SMTP to handle application/Scanner relays into office 365.
This video discusses moving either the default database or any database to a new volume.
Suggested Courses

650 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