Get Recipient type w/PowerShell

Have you ever thought how many recipient types there are in a Hybrid organization? Probably much more than you used to think. Each of us knows several of them, like MailContact, UserMailbox, RemoteUserMailbox, etc. But how things really are?

Get-PExRecipientType

The Get-PExRecipientType function from my PowerShell Power-EXCH module is an automated solution for the workaround, described in this post written by Alex Rizeanu MSFT. The function needs no EMS and no Exchange/EXO connection. All that you need is ActiveDirectory module to invoke Get-ADUser cmdlet and optionally maybe Get-ADGroup or Get-ADGroupMember.

So, let’s go on a simple example

Get-ADUser $Name | Get-PExRecipientType
Get-ADUser $env:USERNAME | Get-PExRecipientType
Get-ADUser $env:USERNAME | Get-PExRecipientType | Format-List

As you can see, all you need is to pass Active Directory user object through the pipeline. Of course, you can pipeline multiple users.

Get-ADUser -LDAPFilter "(&(objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2))" | Get-PExRecipientType
Get-ADUser -Filter * | Get-PExRecipientType

Any LDAP query, that returns Active Directory user(s) will work.

Get-ADGroupMember $ADGroup | Get-ADUser | Get-PExRecipientType
Get-ADGroupMember $ADGroup | Get-ADUser | Get-PExRecipientType | Out-GridView -Title 'Recipients report'
Get-ADGroupMember $ADGroup | Get-ADUser | Get-PExRecipientType | Export-Csv .\RecipientsReport.csv -NoTypeInformation

Filter output

The function supports out of box output filtering. It can be useful when you want to get only certain recipients type, with no mailbox for example.

Get-ADGroupMember $ADGroup | Get-ADUser | Get-PExRecipientType -Filter MailEnabled
Get-ADGroupMember $ADGroup | Get-ADUser | Get-PExRecipientType -Filter NoMailbox

The -Filter parameter is positional and may be omitted. The Ctrl + Space Intellisense will help you to select a right value.

Get-ADGroupMember $ADGroup | Get-ADUser | Get-PExRecipientType RemoteOnly
Get-ADGroupMember $ADGroup | Get-ADUser | Get-PExRecipientType OnPremOnly

Of course, you can filter any of the returned object properties by Where-Object clause. The following example will return only members of the group for which RecipientDetails property contains shared string in its name.

Get-ADUser $env:USERNAME | Get-PExRecipientType | Get-Member
Get-ADGroupMember $ADGroup | Get-ADUser | Get-PExRecipientType | Where-Object { $_.RecipientDetails -match 'shared' }

For more details about this function, please take a look at the content-based help and examples.

Get-Command -Module Power-EXCH
Get-Help Get-PExRecipientType -Full
Get-Help Get-PExRecipientType -Parameter Filter
Get-Alias -Definition Get-PExRecipientType

Please feel free to ask your questions in the comments section and to share this post with your colleges.

You might also like

Put an Exchange Server in and take it out of Maintenance Mode

Filter Exchange Servers by Release Year

Retrieve mailboxes in Hybrid organization

Get Exchange mailbox size

Leave a comment