PowerShell Query: Display mailbox which has a non-primary e-mail address?

Tonito Dux 956 Reputation points
2021-04-02T08:49:07.367+00:00

Hi,

when a colleague leaves the company, we usually attach his e-mail address up to two months to a colleague which worked with him so any e-mail can still be processed and answered.
I would like to create a PS Query which shows me the entered smtp address and then displays to which mailbox is this non-primary e-mail address (alias) assigned.

I had this, but it does not work:

Get-Recipient -ResultSize unlimited | Select Name -expand EmailAddresses | Where {$_.SmtpAddress -match ".FIRSTNAME"} | Format-Table Name, SMTPAddress

I tried entering full e-mail address, first couple of letters and then * but it does not show any results. We have Exchange Online.

Cheers

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,163 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andy David - MVP 141K Reputation points MVP
    2021-04-02T11:37:26.023+00:00

    You are trying to find a mailbox based on a specific email Address?

    get-mailbox <email Address>
    

    is all you need. it will find it even if its not primary

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Tonito Dux 956 Reputation points
    2021-04-02T12:02:40.52+00:00

    This also works fine when we don't want/know the whole alias address:

    Get-EXOMailbox | Where {$_.EmailAddresses -like "SEARCH_TERM"} | select DisplayName, PrimarySMTPAddress