September 3, 2010

How to Remove Mail Users from the Global Address List

The default Global Address List in an Exchange 2007 or Exchange 2010 organization includes all mail-enabled objects.  It does this using the following recipient filter:

((Alias -ne $null -and RecipientType -ne 'MailUser') -and ((((ObjectClass -eq 'user' -or ObjectClass
-eq 'Contact' -or ObjectClass -eq 'msExchSystemMailbox') -or ObjectClass -eq 'msExchDynamicDistributi
onList') -or ObjectClass -eq 'group') -or ObjectClass -eq 'publicFolder'))

You can see that the following object classes are included:

  • User
  • Contact
  • System Mailbox
  • Dynamic Distribution Group
  • Group
  • Public Folder

In some environments it may be desirable to exclude Mail Users.  Mail Users are similar to Contacts in that they do not have a mailbox in the local Exchange organization, however unlike Contacts they do have a user account in Active Directory.

In other words, Mail Users are mail-enabled user objects that use an external email service.

Mail Users are displayed in the same area of the Exchange Management Console as regular Contacts, which may lead you to think that excluding them from the Global Address List is as simple as removing this part of the recipient filter:

-or ObjectClass -eq ‘Contact’

However that is not correct, and will not remove Mail Users from the Global Address List.  To understand how to actually do this take a closer look at the attributes of a Mailbox User and a Mail User.

[PS] C:\>get-mailbox "John Smith" | fl objectclass, recipienttype

ObjectClass   : {top, person, organizationalPerson, user}
RecipientType : UserMailbox

[PS] C:\>get-mailuser "Peter Banes" | fl objectclass, recipienttype

ObjectClass   : {top, person, organizationalPerson, user}
RecipientType : MailUser

Notice that both are the same ObjectClass of ‘user’, which would still be included in the recipient filter if you were to simply remove the ‘Contact’ object class.

Instead, to remove Mail Users from the Global Address List you should exclude them by Recipient Type. You can do this by including the following condition in your recipient filter:

RecipientType -ne ‘MailUser’

For example:

Set-GlobalAddressList "Default Global Address List" -RecipientFilter {(Alias -ne $null -and RecipientType -ne 'MailUser' -and (ObjectClass -eq 'user' -or ObjectClass -eq 'Contact' -or ObjectClass -eq 'msExchSystemMailbox' -or ObjectClass -eq 'msExchDynamicDistributionList' -or ObjectClass -eq 'group' -or ObjectClass -eq 'publicFolder'))}

If you’re making this change to the default Global Address List see my previous post with the solution to the error that occurs when modifying the default Global Address List.

Comments

  1. Scott says:

    How exactly did you “remove” this person from the Global Address List? Knowing that will determine where to go next.

    • I excluded the MailUser recipient type from the GAL query, ie the “RecipientType -ne ‘MailUser” bit you see above.

      This removes all Mail User recipient types from the GAL in question.

Leave a Comment

*