I'm looking to create an Office 365 transport rule to allow inbound emails from selected IP addresses to bypass the spam filter.

Can someone please help?

The closest I've been able to come up with is:

Set-TransportRule -Name "Whitelist" -ExceptIfSenderIpRanges {,,,} -SetSCL -1

Thanks for your help!

  • Something like this? $ips =@("","") foreach ($ip in $ips){Set-TransportRule -Name "Whitelist" -ExceptIfSenderIpRanges $ip -SetSCL -1} – Smeerpijp Dec 14 '17 at 10:20
  • Thanks for your help. Running these commands shows error: Starting a command on the remote server failed with the following error message : The I/O operation has been aborted because of either a thread exit or an application request. For more information, see the about_Remote_Troubleshooting Help topic. + CategoryInfo : OperationStopped: (outlook.office365.com:String) [], PSRemotingTransportException + FullyQualifiedErrorId : JobFailure + PSComputerName : outlook.office365.com – Ash Dec 14 '17 at 23:30

CSV file:

enter image description here


$IPs = Import-Csv C:\root\IP.CSV
$IpRange =$IPs.IP
Get-TransportRule  <Rule Name> | Set-TransportRule -ExceptIfSenderIpRanges $IPRange
Get-TransportRule  <Rule Name>  |fl  ExceptIfSenderIpRanges

Figure as below: enter image description here

$UserCredential = Get-Credential
Set-ExecutionPolicy RemoteSigned
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
Get-Mailbox | Set-MailboxJunkEmailConfiguration –Enabled $False

We can do it by Content Filter setting or Transport rule. For your reference: How to Whitelist by IP Address in Exchange 2013, 2016, or Office 365

  • I understand how to do it via the Exchange Admin Center, however this process only allows to add one IP address at a time. I have to add 83 IP addresses per Office 365 tenant for about 10 tenants, therefore am looking for a PowerShell command. – Ash Dec 14 '17 at 5:01
  • Well, I suppose that there's a csv file for those IP addresses. If so, we can do it by command. Check it in my new reply. – Jianfei Wang Dec 18 '17 at 4:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.