I work with Exchange Online and Azure AD quite a lot and I’m constantly looking up the same commands to do simple things.
This is a cheat-sheet of the common commands so I don’t have to keep looking them up:
Searching for the owner of a mailbox:
There are a number of ways to do this but this is the most reliable one
Get-Mailbox -IncludeInactiveMailbox -Identity * | Where-Object {$_.EmailAddresses -like ‘*info*@domain.com’} | Format-List Identity, EmailAddresses
Finding Inbox-Rules
Get-InboxRule -mailbox ‘info@domain.com’ | select Name,Description
Removing Inbox-Rules (en masse)
Get-InboxRule -mailbox ‘info@domain.com’ | Remove-InboxRule
Find out if any accounts in the tenant have mail forwarding:
Get-Mailbox -ResultSize Unlimited | Where {($_.ForwardingAddress -ne $Null) –or ($_.ForwardingsmtpAddress -ne $Null)} | Select Name, ForwardingAddress, ForwardingsmtpAddress, DeliverToMailboxAndForward
Set-Mailbox user@domain.com -ForwardingAddress $NULL -ForwardingSmtpAddress $NULL
Get-TransportServer | Get-MessageTrackingLog -ResultSize Unlimited -Start “mm/dd/yyyy 00:00:00 AM” -End “mm/dd/yyyy 00:00:00 AM” -Sender someone@domain.com | Select {$_.Recipients}, {$_.RecipientStatus}, * | Export-Csv D:ReportsSent_Nuno.csv –NoTypeInformation
Another helpful thing I found – a lot of queries in Exchange Online truncates the output so you end up with {blah;blah;blah…}
If that happens there are two ways to address it:
- Pipe the output to FT or FL with -Wrap -Autosize
- Set the $formatEnumerationLimit: $FormatEnumerationLimit =-1
I’ll update this list on a regular basis moving forward.