Get-Recipient works very well when looking for all SMTP addresses including Distribution Groups and Contacts.
Get-Recipient -resultSize unlimited | select name -expand emailAddresses | where {$_.smtpAddress -match “.*info@.*”} | Format-Table name, smtpaddress
Here’s another one I find I use a lot. In large organizations trying to figure out who has what alias can be extremely difficult unless you use the EMC. By modifying “.*info@.*” with whatever your looking for is a huge time saver.
I have found this code to be a bit unreliable lately so I’ve started using this:
Get-Mailbox -Identity * | Where-Object {$_.EmailAddresses -like ‘*info*@tenantdomain.com’} | Format-List Identity, EmailAddresses
Using -like allows you to use wildcards in the search which is extremely helpful when looking for derivatives. However, the search itself is limited to mailboxes (Get-Mailbox).
I need to spend some time recoding Get-Recipient to do the same thing.
Get-Recipient -ResultSize Unlimited | Select Name -expand EmailAddresses | where {$_.SMTPAddress -like “*info*@*”} | Format-Table Name,SMTPAddress