Search for email in Office 365 or AD or Exchange

About:

This PS code is used to search for email inside Office 365. It searches in everything such as email addresses, and alias.

The code works on-prem or on cloud

Code:

Get-Mailbox -Identity * | Where-Object {$_.EmailAddresses -like ‘smtp:QualityiAuditor@ridley.com.au’} | Format-List Identity, displayname

Get-Mailbox -Identity * | Where-Object {$_.EmailAddresses -like ‘production*’ -or $_.PrimarySmtpAddress -like ‘production*’} | Format-List Identity, displayname

Notes:

You will need the PS script to connect to office 365 at first.