Date created: 12/11/11 20:20:58. Last modified: 12/13/12 11:41:20

List Domains and Primary Addresses

This will list the domains for which a mail server routes mail. Also it lists all mailboxes that have that domain set as their primary SMTP address;

$AcceptedDomains = Get-AcceptedDomain | select DomainName
foreach ($EachDomain in $AcceptedDomains)
  echo $EachDomain.DomainName.toString(); Get-Mailbox | where {$_.PrimarySMTPAddress -like ("*" + $EachDomain.DomainName)} | sort-object Name | fl Name, PrimarySMTPAddress

Example output:

Name               : User 123
PrimarySmtpAddress : [email protected]

Name               : Info
PrimarySmtpAddress : [email protected]

Name               : helpdesk
PrimarySmtpAddress : [email protected]

Name               : CEO Dave
PrimarySmtpAddress : [email protected]

Previous page: Export to PST
Next page: List Primary SMTP Addresses