Solved

Method of obtaining only users with mailboxes, per OU

Posted on 2014-01-10
5
367 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
  • 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 250 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 38

Accepted Solution

by:
Adam Brown earned 250 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
In this video we show how to create a mailbox database 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 >> Data…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

895 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

15 Experts available now in Live!

Get 1:1 Help Now