Quick answer: Get-MailContact lists the mail contacts (external email addresses) in your Exchange Online or Exchange Server organization. Run it with no parameters to list them all, or name one contact:
Get-MailContact -ResultSize Unlimited
Get-MailContact -Identity "Chris Ashton" | Format-List
It returns up to 1,000 contacts by default. Add -ResultSize Unlimited to get every one.
Before you start
- Connect. Run
Connect-ExchangeOnline(Exchange Online) or open the Exchange Management Shell (on-premises). - Permissions. You need Exchange permissions assigned before you can run the cmdlet. Some parameters may be missing if your role doesn't include them.
- Pick the right cmdlet.
Get-MailContactshows mail-related properties such asExternalEmailAddress.Get-Contactshows contact details such as department and phone, but no mail properties. See Get-MailContact vs Get-Contact.
Syntax
Get-MailContact has two parameter sets. Use -Identity for one contact or -Anr for a partial-name search:
Get-MailContact
[[-Identity] <MailContactIdParameter>]
[-Credential <PSCredential>]
[-DomainController <Fqdn>]
[-Filter <String>]
[-IgnoreDefaultScope]
[-OrganizationalUnit <OrganizationalUnitIdParameter>]
[-ReadFromDomainController]
[-RecipientTypeDetails <RecipientTypeDetails[]>]
[-ResultSize <Unlimited>]
[-SortBy <String>]
[<CommonParameters>]
Get-MailContact
[-ANR <String>]
[... same parameters as above, without -Identity]
Parameters
| Parameter | What it does |
|---|---|
-Identity |
Position 1. Name, alias, email address, DN, canonical DN or GUID. Accepts pipeline input |
-ANR |
Ambiguous name resolution: a partial match on CN, DisplayName, FirstName, LastName or Alias |
-Filter |
OPATH filter, for example "ExternalEmailAddress -eq 'chris@tailspintoys.com'" |
-ResultSize |
Maximum results. Default 1000. Use Unlimited for all |
-SortBy |
Sort ascending by one property: Name, DisplayName or Alias |
-RecipientTypeDetails |
MailContact or MailForestContact. Separate several with commas |
-OrganizationalUnit |
Return only contacts in this OU or domain |
-Credential, -DomainController, -IgnoreDefaultScope, -ReadFromDomainController |
On-premises only |
Caution: a $null or non-existent -Identity value returns every contact, as if you left -Identity off. Check lists of identities before piping them in.
Examples
List all mail contacts
Get-MailContact -ResultSize Unlimited
Show every property of one contact
Get-MailContact -Identity "Chris Ashton" | Format-List
Find contacts by partial name
Get-MailContact -Anr Chris
Find the contact for an external address
Get-MailContact -Filter "ExternalEmailAddress -eq 'chris@tailspintoys.com'"
Find all contacts at one domain
With wildcards, include the smtp: prefix. Without it, the filter doesn't match:
Get-MailContact -ResultSize Unlimited -Filter "ExternalEmailAddress -like 'smtp:*@tailspintoys.com'"
Find contacts hidden from the address list
Get-MailContact -ResultSize Unlimited -Filter 'HiddenFromAddressListsEnabled -eq $true'
The filter uses single quotes because it contains $true.
Find contacts created after a date
Get-MailContact -ResultSize Unlimited -Filter "WhenCreated -gt '11/1/2026'"
Sort by display name
Get-MailContact -ResultSize Unlimited -SortBy DisplayName
Export all mail contacts to CSV
Get-MailContact -ResultSize Unlimited |
Select-Object DisplayName, Alias, ExternalEmailAddress, PrimarySmtpAddress, HiddenFromAddressListsEnabled |
Export-Csv -Path .\mailcontacts.csv -NoTypeInformation
Contacts in one OU
Get-MailContact -OrganizationalUnit "contoso.com/Vendors"
Get-MailContact vs Get-Contact
Get-MailContact |
Get-Contact |
|
|---|---|---|
| Returns | Mail contacts | Contacts and mail contacts |
Mail properties (ExternalEmailAddress, EmailAddresses) |
Yes | No |
Contact details (Department, Company, Phone) |
No | Yes |
-RecipientTypeDetails values |
MailContact, MailForestContact |
Contact, MailContact, MailForestContact |
-SortBy values |
Name, DisplayName, Alias | Name, DisplayName, City, FirstName, LastName, Office |
Department and Company aren't filterable on Get-MailContact. To find mail contacts in one department, use Get-Contact:
Get-Contact -RecipientTypeDetails MailContact -Filter "Department -eq 'Sales'"
Create or change a mail contact
New-MailContact needs -Name and -ExternalEmailAddress:
New-MailContact -Name "Chris Ashton" -ExternalEmailAddress "chris@tailspintoys.com"
Set-MailContact changes one. For example, to hide a contact from address lists:
Set-MailContact -Identity "Chris Ashton" -HiddenFromAddressListsEnabled $true
Troubleshooting
- Only 1,000 contacts come back. That's the default
-ResultSize. Add-ResultSize Unlimited. - "Not a recognized filterable property". The property isn't filterable on
Get-MailContact.DepartmentandCompanywork onGet-ContactorGet-Recipient. - A wildcard address filter returns nothing. Add the
smtp:prefix, as in'smtp:chris*'. - A parameter isn't found.
-Credential,-DomainController,-IgnoreDefaultScopeand-ReadFromDomainControllerexist only on-premises. Other missing parameters mean your role doesn't include them.
FAQ
What's the difference between Get-MailContact and Get-Contact?
Get-MailContact shows mail properties like the external address. Get-Contact returns all contacts, mail-enabled or not, with no mail properties.
How do I get all mail contacts?
Get-MailContact -ResultSize Unlimited. Without -ResultSize, it stops at 1,000.
How do I export mail contacts to CSV?
Pipe Get-MailContact -ResultSize Unlimited to Select-Object and Export-Csv, as in the export example above.
Does Get-MailContact work in Exchange Online?
Yes. It works in Exchange Online and in Exchange Server 2010 through Exchange Server SE.
Sources: Get-MailContact, Get-Contact, New-MailContact, Set-MailContact and Filterable properties for the Filter parameter on Microsoft Learn.
Managing Microsoft 365 rooms too? Meeting Room 365 turns any tablet into a room display for Outlook and Teams calendars.