The below is a little example of how to extract a list of the configured Office 365 email forwarding settings using the cmdlet get-mailbox for all mailboxes

Three columns will be returned;

  • UserPrincipalName: The users Office 365 username
  • ForwardSmtpAddress: If defined this is the email address messaged are being forwarded to, else forwarding is not enabled.
  • DeliverToMailboxAndForward: If set to true a copy is keep in the mailbox in addition to being forwarded, else no local copy is retained.

 

Connecting to Office 365

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

Displaying as a list in the PowerShell window

Get-Mailbox | select UserPrincipalName,ForwardingSmtpAddress,DeliverToMailboxAndForward

Exporting the list as a CSV file

Get-Mailbox | select UserPrincipalName,ForwardingSmtpAddress,DeliverToMailboxAndForward | Export-csv D:\Office365Forwards.csv -NoTypeInformation