How to check mail forwarding in office 365 powershell

To check mail forwarding in Office 365 using PowerShell, you can use the following commands:

Get-MailboxForwarding

This cmdlet retrieves the forwarding settings for a specified mailbox. You can use the -Identity parameter to specify the mailbox alias or email address.

Example:

Get-MailboxForwarding -Identity <mailbox_alias>

Replace <mailbox_alias> with the actual alias or email address of the mailbox you want to check.

Get-Mailbox

This cmdlet retrieves the mailbox properties, including forwarding settings. You can use the -Identity parameter to specify the mailbox alias or email address.

Example:

Get-Mailbox -Identity <mailbox_alias> | fl ForwardingAddress

Replace <mailbox_alias> with the actual alias or email address of the mailbox you want to check. The fl cmdlet is used to format the output as a table, and the ForwardingAddress property will display the forwarding address if it exists.

Get-MailboxStatistics

This cmdlet retrieves mailbox statistics, including forwarding settings. You can use the -Identity parameter to specify the mailbox alias or email address.

Example:

Get-MailboxStatistics -Identity <mailbox_alias> | fl ForwardingEnabled

Replace <mailbox_alias> with the actual alias or email address of the mailbox you want to check. The fl cmdlet is used to format the output as a table, and the ForwardingEnabled property will display a value of $True if forwarding is enabled.

Get-TransportRule

This cmdlet retrieves transport rules, which can include mail forwarding rules. You can use the -Identity parameter to specify the rule name or ID.

Example:

Get-TransportRule -Identity <rule_name>

Replace <rule_name> with the actual name of the transport rule you want to check. The output will include information about the rule, including the forwarding address if it exists.

Note: You need to have the necessary permissions and credentials to run these PowerShell commands. Additionally, you may need to use the -ConnectionUri parameter to specify the Office 365 tenant URL, for example:

$cred = Get-Credential
Connect-ExchangeOnline -UserPrincipalName <username> -ShowProgress $true -ConnectionUri https://outlook.office365.com/powershell/

Replace <username> with your Office 365 username.