Getting Exchange Server Recipients from Active Directory

I run into a strange issue today where I had to get a list of all the users that had a mailbox without having access to any Exchange servers. It was crucial that the list did not contain any MailUsers or MailContacts since those objects are managed using Microsoft Identity Manager (MIM).

Since I could not access any Exchange servers, the use of the Get-Mailbox cmdlet was out of the question. I had to go to the source, the Active Directory. Exchange depends heavily on Active Directory and that was the place I would find the information I needed.

So, I fired up Powershell ISE and loaded the activedirectory module. In order to filter the objects, we are going to use the msExchRecipientTypeDetails attribute. The values of this attribute represent the different Exchange Recipient Types. You can find more details about the values here: https://blogs.technet.microsoft.com/dkegg/2014/05/09/msexchrecipienttypedetails/

Since I only want the users with a mailbox, I am going to use the Get-ADUser cmdlet and filter using the value of "1".

Get-ADUser -Filter {msExchRecipientTypeDetails -eq 1} -ResultSetSize $null

I've also set the ResultSetSize parameter to $null since I want to get all the results. You may get an error here if the results are more than 5000 and you are using Active Directory Web  Services, so open Powershell on a domain controller.

Popular posts from this blog

Syslog Message Collection for OMS from sources that do not support the agent

How to Configure Message Forwarding on a Mailbox Level

Generating Alerts On OMS