Friday 27 May 2016

Exchange report all users with a particular email address domain

For on premise exchange servers:

Launch an Exchange Management Shell and run this command, substituting domain.com for the you want to look for such as mydomain .com


Get-Mailbox -resultsize unlimited | Select-Object displayname -expandproperty emailaddresses| Where-Object {$_.smtpaddress -like "*domain.com*"}| Select-Object displayName,SmtpAddress | Export-csv C:\domain.csv

This will save a .csv file to your C drive with a list of accounts that have an email address for that domain


For Exchange Online:

Launch a powershell session and run Connect-msolservice. Enter your 365 credentials then run the command below


Get-MsolUser -ReturnDeletedUsers | Where {$_.ProxyAddresses -like "*@mydomain.com"} | FL DisplayName,UserPrincipalName , ProxyAddresses

This will output the results to your powershell terminal