Setting Up SMTP Forwarding Via PowerShell on Office 365

These are the commands needed to set up SMTP forwarding for an email address in Office 365 using PowerShell.

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking
Set-Mailbox -ForwardingSmtpAddress "" -Identity ""
Remove-PSSession $Session