How to Add Remote IP Addresses to Existing Receive ConnectorsThe Exchange Management Shell provides the Set-ReceiveConnector cmdlet for modifying settings on Hub Transport server Receive Connectors. This can include the RemoteIPRanges setting, which is the multivalued list of IP addresses on the network that are allowed to use that Receive Connector to send mail.

Most Exchange environments will include at least one Receive Connector that is configured to allow certain hosts and applications to relay email. Over time this may build up a lengthy RemoteIPRanges IP address list. When it comes time to add additional IP addresses to the list it seems logical to use Set-ReceiveConnector, however this cmdlet will overwrite the existing setting with the new IP address specified.

For example, look at the current IP addresses:

[PS] C:\>Get-ReceiveConnector "Relay Connector" | fl remoteipranges

RemoteIPRanges : {,,,,,,,,, 10

Note: if the list of IP addresses is too long and is being truncated in the shell output see this tip for extending the enumeration limit.

Now use Set-ReceiveConnector with a new IP of

[PS] C:\>Set-ReceiveConnector "Relay Connector" -RemoteIPRanges

And whoops, we’ve overwritten all of the previous IP addresses!

[PS] C:\>Get-ReceiveConnector "Relay Connector" | fl remoteipranges

RemoteIPRanges : {}

If you were just adding one new IP address the Management Console would do the job, but that can be slow for remote servers and is not as efficient if the change is being applied to multiple servers or involves adding multiple IP addresses.

Fortunately with the Exchange Management Shell we can easily add IP addresses to existing Receive Connectors.

To add a single IP address to an existing Receive Connector:

[PS] C:\>$RecvConn = Get-ReceiveConnector "Relay Connector"
[PS] C:\>$RecvConn.RemoteIPRanges += ""
[PS] C:\>Set-ReceiveConnector "Relay Connector" -RemoteIPRanges $RecvConn.RemoteIPRanges

Now we can see that has been added to the Receive Connector.

[PS] C:\>Get-ReceiveConnector "Relay Connector" | fl remoteipranges

RemoteIPRanges : {,,,,,,,,, 10.0.
                 0.13,,,,,,,,,, 10.

To add multiple IP addresses at once use this command sequence:

[PS] C:\>$RecvConn = Get-ReceiveConnector "Relay Connector"
[PS] C:\>$RecvConn.RemoteIPRanges += "", "", ""
[PS] C:\>Set-ReceiveConnector "Relay Connector" -RemoteIPRanges $RecvConn.RemoteIPRanges

Sometimes the list of IPs being added is too long to type out. To add multiple IP addresses from a text file called newips.txt use this command sequence instead:

[PS] C:\>$RecvConn = Get-ReceiveConnector "Relay Connector"
[PS] C:\>Get-Content .\newips.txt | foreach {$RecvConn.RemoteIPRanges += "$_"}
[PS] C:\>Set-ReceiveConnector "Relay Connector" -RemoteIPRanges $RecvConn.RemoteIPRanges

About the Author

Paul Cunningham

Paul is a former Microsoft MVP for Office Apps and Services. He works as a consultant, writer, and trainer specializing in Office 365 and Exchange Server. Paul no longer writes for


  1. Stefano

    I’m trying to copy receive connectors from ex2010 to ex2016 but I get the following error

    Cannot process argument transformation on parameter ‘RemoteIPRanges’. Cannot convert value “” to type “Microsoft.Exchange.Data.MultiValuedProperty`1[Microsoft.Exchange.Data.IPRange]”. Error:
    “Cannot convert value “” to type “Microsoft.Exchange.Data.IPRange”. Error:
    “SerializationTypeConverter.DeserializeObject(Microsoft.Exchange.Data.IPRange). Type is not allowed for custom
    construction. Deserialization Failed Error: System.Exception: SerializationData is not signed.
    at Microsoft.Exchange.Data.SerializationTypeConverter.VerifySerializationDataAndGetOriginalSerializationData(Byte[]
    serializationData, Boolean mustVerify)
    at Microsoft.Exchange.Data.SerializationTypeConverter.DeserializeObject(Object sourceValue, Type destinationType)””
    + CategoryInfo : InvalidData: (:) [New-ReceiveConnector], ParameterBindin…mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,New-ReceiveConnector

    1. Simao

      I have same problem, same script worked wile ago and now I get same error. Maybe it is related to exchange update.

    2. Oleg Krylov

      It’s related to EMS remote connection serialization. Even if you run EMS on the Exchange Server it uses remote connection even to local server. Two workarounds here:
      1. Run Windows PowerShell on the Exchange Server and import Exchange Management snap-in
      Add-PSSnapin -Name “Microsoft.Exchange.Management.PowerShell.SnapIn”
      2. Connect to Exchange remotely using web powershell and Exchange JEA configuration:
      $ConnectionURL = “http:///PowerShell”
      $PSSession = New-PSSession -ConfigurationName “Microsoft.Exchange” -ConnectionUri $ConnectionURL -Authentication “Kerberos”
      Import-PSSession -Session $PSSession

      1. Oleg Krylov

        CSS stripped ServerFQDN in angle brackets from $ConnectionURL

  2. Question

    in your get- commands, you preceed the command with “>” What is that for? Looks like &gt is “greater than”. But that isn’t needed to run the command and when I use that in my lab, I get errors.

  3. Raul

    Getting below error while running set-recieveconnector:

    Set-ReceiveConnector : Active Directory operation failed on localhost. This error is not retriable. Additional
    information: While accessing the hard disk, a disk operation failed even after retries.
    Active directory response: 00000467: SysErr: DSID-0203065E, problem 14 (Bad address), data -510

    Anyone has any clue?

  4. PG

    What is the syntax C:\> for

  5. Ian Hazlewood

    Great article. Is it possible to specifically exclude IP addresses?

  6. Chuck Williams

    This is awesome. We are moving IPs from some legacy 2010 servers to 2013 servers. The script works, but we have quite of few IPs that are already on the 2013 server.
    How to run the script and keep it running so it bypasses any IPs in the text file that are already on the 2013 server?

    I am running this:

    $ReceiveConnector = Get-ReceiveConnector “Name Of Relay”
    Get-Content C:list.txt | foreach {$ReceiveConnector.RemoteIPRanges += “$_”}
    Set-ReceiveConnector $ReceiveConnector -RemoteIPRanges $ReceiveConnector.RemoteIPRanges stops when it finds an IP that already exist on the targeted 2013 server…any ideas?

    Thanks a ton.

    1. Avatar photo
      Paul Cunningham

      This approach works best for new connectors with no existing remote IP configs that will conflict.

      In your case you will need to write some script code to also pull the remote IP ranges from the new connector, and then as you loop through the list to add, checks if it already exists and skips it if it does.

      1. Chuck Williams

        Any sample code you can share?

        On the 2013 server, we have about 6 RCs and the new RC is #6. So once I export all the IPs from the to put them in separate text file and do the comparison with the existing text file of IPs I am trying to import into the new RC#6.

        I am not a scripting expert…thus was looking for some assistance…thanks a ton.

        1. Avatar photo
          Paul Cunningham

          I don’t have sample code for that, sorry. To be honest it is probably only a couple of hours research at most even for a beginner to PowerShell.

          1. Chuck Williams

            Thanks Paul,

            I’ll continue researching…thanks a ton.


        2. Hugo Cardoso

          Hi dude,
          Just came across this post, and I had more or less the same need. I know its been a long time, bull ill leave this here anyway.

          I had a list of ips that may or may not be already added to the connector. So I built this code that only adds the IP if it is not present:

          #CSV has header “ips”
          $IPListcheck=Import-csv c:\list.txt
          #The existing receive connector
          $RecvConn = Get-ReceiveConnector “Transport_Server\AnonymousRelay”
          foreach($iprange in $ranges){
          $ipExistente= ($iprange | Select LowerBound).LowerBound
          #write-host “comparing “$currentip” with “$ipExistente
          if($currentip -eq $ipExistente){
          #write-host “debug if next”
          if($exists -eq $false){
          $RecvConn.RemoteIPRanges += $currentip
          write-host “added ” $currentip
          Set-ReceiveConnector “Transport_Server\AnonymousRelay” -RemoteIPRanges $RecvConn.RemoteIPRanges

  7. Mahendra

    getting error below when i try to add multiple ip from txt file

    [PS] C:\Windows\system32>$RecvConn = Get-ReceiveConnector “crm”
    [PS] C:\Windows\system32>C:\>Get-Content .iplist.txt | foreach {$RecvConn.RemoteIPRanges += “$_”}
    The term ‘C:\>Get-Content’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check
    the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:16
    + C:\>Get-Content <<<Get-Content:String) [], CommandNotFoundException

    can someone help me…

    1. Avatar photo
      Paul Cunningham

      You’ve pasted the C:\> prompt in with the command, that is why it is throwing the error.

  8. Brindha


    My question: I want to compare the remote IP’s of the receive connectors on two different servers (one old and one new) and add the ones missing to the new server. Is there any command for that ? I have been exporting the remote IP’s and comparing them one by one one each.


    1. Mahendra

      use vlookup in excel

  9. Stewart Petersen

    Would something like this work for removing an IP from the remote IP range.
    $rc = Get-ReceiveConnector “Relay Connector”
    $relay = “IP to be removed”
    $Array = @()
    $ips = $rc.RemoteIPRanges
    foreach($ip in $ips){
    if ($ip -eq $relay){Write-Host Cleared}
    else {$Array += $ip}
    Set-ReceiveConnector “Relay Connector” -RemoteIPRanges $Array

      1. Stewart Petersen

        I tested it today.
        A simple version would look like this.
        $ip = “IP”
        $rc = Get-ReceiveConnector “Relay Connector”
        $NewRange = @()
        $OldRange = $rc.RemoteIPRanges
        foreach ($rip in $OldRange){
        if ($rip -eq $ip) {Write-Host “$ip Cleared”}
        else {$NewRange += $rip}
        Set-ReceiveConnector “Relay Connector” -RemoteIPRanges $NewRange

        What I am actually using is a bit different. I added few prompts, and entry checks. I am also using mine to add to 4 servers at once. So it looks closer to this:
        #Prompt for IP
        $run = {
        $ip = Read-Host -Prompt “Enter Server IP”
        #Confrim IP entery is a Valid IP
        $test = ($ip -as [ipaddress]) -as [bool]
        #get RC
        $rc = Get-ReceiveConnector “Relay Connector”
        If ($test -eq $false){
        Write-Host “$ip is not a valid IP Address” -ForegroundColor Red
        Else {
        #check if IP exsist
        $check = “”
        $check = $rc | fl | where {$rc.RemoteIPRanges -Contains “$ip”}
        if ($check.Length -eq 0) {Write-Host “$ip Does Not Exist on this Server” -ForegroundColor red}
        else {
        $ip = Read-Host -Prompt “Enter Server IP”
        $rc = Get-ReceiveConnector “Relay Connector”
        $NewRange = @()
        $OldRange = $rc.RemoteIPRanges
        foreach ($rip in $OldRange){
        if ($rip -eq $ip) {Write-Host “$ip Cleared”}
        else {$NewRange += $rip}
        Set-ReceiveConnector “Relay Connector” -RemoteIPRanges $NewRange
        $andanotherone = Read-Host “Would You Like to Add Another Relay?”
        if ($andanotherone -eq “y”) {&$Run}
        Else {Exit}

        1. Waleed

          can u make it clear please with samples

    1. gpburth

      There’s an easier way: just replace the += with -=:
      $RecvConn.RemoteIPRanges -= “”

      works at least in Exchange2013

  10. rino19ny

    hi, i got mine like this:

    $ReceiveConnector = Get-ReceiveConnector “cas2Allow Relay External Emails”
    Get-Content d:list.txt | foreach {$ReceiveConnector.RemoteIPRanges += “$_”}
    Set-ReceiveConnector $ReceiveConnector.Identity -RemoteIPRanges $ReceiveConnector.RemoteIPRanges

    and got error message:

    Cannot process argument transformation on parameter ‘RemoteIPRanges’. Cannot convert value “…”

  11. Koen

    Hi Paul… I know it’s not the correct collum too ask.
    But we have reach the maximum of the RemoteIPRanges of our RecieveConnector.
    Is there a parameter to extend above the 1250 items?

  12. Sven Minor

    In Exchange Server 2016. I go into EAC –> MailFlow –>Receive Connectors –> Relay –>Scoping –>*Remote network settings: Receive mail from servers that have these remote IP addresses. Do you know of any way to bulk add specific IP addresses into the remote Network Settings?

      1. zeeshan

        adding a single ip address from remote ip from EAC –> MailFlow –>Receive Connectors –> Relay –>Scoping –>*Remote network settings should not remove old ip addresses from the existing receive connector is it Paul ? also, how to get the type of connector (example internal external or custom)

  13. Gary Jackson

    I’m trying to reduce my exposure of my internal relay connector. My issue is though I have ranges included throughout in addition to IPs. How can I gather logs and determine which actual IPs are hitting my connector so I can remove these ranges after adding the IPs? I had feeling like I’m over exposed. Thanks!

  14. TED

    Thanks for the info… but I need remove multiples IP from the connector and I’m not sure how is the command for remove a multiple IP.

  15. Greg Powlin

    What is the default setting when Exchange s first installed?

  16. CMRamos

    Great post with clear and concise instructions for importing, BUT what about exporting the “RemoteIPRanges” to a single column LIST IP’s, Ranges and Subnets already in the relay? Something that we can more easily read, imported into a spreadsheet, and reconciled to update the permitted hosts as you outlined above?

    i.e. We want the TXT output to list

    And NOT…,,,

    1. Michael H.

      $IPs=(Get-ReceiveConnector “ExchangeServerDefault ExchangeServer”).RemoteIPRanges
      foreach($IP in $IPs) {
      Switch ($IP.RangeFormat) {
      “SingleAddress” {$RemoteIPs += $IP.LowerBound.ToString()}
      “LoHi” {$RemoteIPs += ($IP.LowerBound.ToString() + “-” + $IP.UpperBound.ToString())}
      “CIDR” {$RemoteIPs += ($IP.LowerBound.ToString() + “/” + $IP.CIDRLength.ToString())}
      $RemoteIPs | Out-File RemoteIPRanges.txt

  17. Eddie

    When adding or removing an ip address to our smtp relay connector we receive this error:
    “Starting acommand on remote server failed with the following error message: The WinRM client sent a request to the remote WS-Management service and was notified that the request size exceeded the configured MaxEnvelopeSize Quota. For more information, see the about_Remote_Troubleshooting Help topic.”

    The MaxEnvelopeSizekb settings is default at “500”, and increasing it to 700 doesn’t solve this problem. Does someone have an idea how to and where to look for, its not the MaxEnvelopeSize in my opion.

    1. Greg Powlin


      Did you get an answer on this? I have a similar issue and increasing to 700 did help, but didn’t resolve issue for larger queries.


  18. Tim Kuhnell


    Can I add subnets like

    To an existing receive connector?

    Thanks in advance.


    1. Liran Zamir

      Hi Tim

      The answer is yes.
      In the text file you can add subnets and ranges like this:


  19. Rob

    Fantastic! Saved hours of manual entry. Thanks again Paul.

  20. Rossell

    Excellent post! Thanks

  21. David Lockridge

    I figured out a loop for multiple Rec Connectors. It throws and error, but still adds the new IPs and keeps the old ones. In my environment, I have “Internal Only” and “External Allowed” connectors on multiple servers.

    $INTRecConns = Get-ReceiveConnector |Where {$_.Name -like “*Internal*”}
    $File = “C:TempNewINTIps.txt”

    Foreach ($Conn in $INTRecConns) {
    $i = Get-ReceiveConnector $Conn
    Get-Content $File |foreach {$i.RemoteIPRanges += “$_”}
    Set-ReceiveConnector $i -RemoteIPRanges $i.RemoteIPRanges

  22. Dave

    I have a question on doing the converse – removing one or more IP’s from a Receive connector for a situation when a relay server is decommissioned. Would that simply involve changing the += below to a -= ?

    Get-Content .newips.txt | foreach {$RecvConn.RemoteIPRanges += “$_”}

    1. Avatar photo
      Paul Cunningham

      I tend to just manually remove them when decommissioning a server that was allowed to relay 🙂

      1. Ranga

        Hi Paul , We have relay enabled in Exchange 2013 EDGE server. Hence we can’t manually remove single ip from console .
        So to remove the single ip . -= correct ?

  23. vadim

    Ok, thanks. Will try. In the past I had some troubles of getting the properly formatted text file to be used with Win PowerShell for input. Maybe thats how I made it work – putting records in line by line.

  24. vadim

    Helpful article (and following comments). One question – talking about text file used for importing IPs, what exactly is the format of records in the file? Just type in all IPs row by row, comma delimited, one IP per line? Or else?

  25. Joakim

    Thanks for replying, Yes it can ping the server normally (with hostname and ip address). For the antivirus, I’m not really sure it block the outbound SMTP because it can telnet the old exchange 2003 server as well.
    I’ll enable the Protocol Logging on the RC to see if it works.

    Thanks again

  26. Joakim


    We migrated from exchange 2003 to 2010. We have many servers and application using the old server, so I had to put one by one the ip address of these application server to the new Relay connector on the new exchange 2010 so they can send email. Every thing is working fine, but only one server could not telnet this relay server. I’ve already add the IP on the list. It can telnet the exchange 2003 not the 2010.
    I got the error below
    Connecting To mgprelay01…Could not open connection to the host, on port 25: Connect failed

    Could you help please?

    1. Avatar photo
      Paul Cunningham

      Can you ping the server? Not a simple routing issue?

      I’ve seen firewalls (both network and client firewalls) as well as some antivirus products cause problems like that (eg preventing outbound SMTP from the server because it looks like a worm/trojan). So check for those.

      What you can also do is enable Protocol Logging on the Receive Connector on the server you’re trying to telnet to, then inspect the protocol logs after trying to make the connection to see whether the traffic is hitting it or not.

  27. Josh

    Excellent Post. Very helpful.
    Thank you.

  28. Holt Satterfield

    Hey, Paul —

    We just built an Exchange 2010 and migrated all the mailboxes from the old 2003 Exchange box. My integrator says he usually adds ALL the IP addresses (and in our case, all the subnet ranges) into the Relay Connector. This is opposed to just devices that usually send mail — scanners, copiers, accounting/equitrac servers.

    What say you about adding all my IP ranges into the Exchange 2010 Relay Connector?

    1. Avatar photo
      Paul Cunningham

      It is a “low effort” approach. I’ve permitted entire IP ranges in some cases before, usually for things like desktop apps that need direct SMTP relay but the pc’s are on a DHCP range without reservations (reservations might sound like a logical solution to that, but they add “yet another thing” to manage and will of course break if the user gets a new pc or logs on to a different one).

      I wouldn’t do it on insecure networks, eg wireless where a guy in his car outside the building uses your server to relay spam.

      And as long as they aren’t creating an open relay that can be exploited from the internet then it’s probably fine.

  29. aaron

    Hey Paul,

    My list of receive connectors is truncated … Even when results outputted to .txt file. Is there a way to have it show the entire list

    [PS] C:\>Get-ReceiveConnector “internal relay” |fl remoteipranges >C:UsersuwhadminDocumentsoutputremoteip.txt

    RemoteIPRanges : {,,,,,,,,,,,,,,,…}

  30. Liran Zamir

    Strangest thing
    Exchange 2010 SP1+Rollup 4. When running the import with a text file containing a list of IP addresses
    the following error occurs for each IP address:

    [PS] C:Windowssystem32>Get-Content .iplist.txt | foreach {$RecvConn.RemoteIPRanges += “$_”}
    Exception setting “RemoteIPRanges”: “Cannot convert value “System.Object[]” to type “Microsoft.Exchange.Data.MultiValue
    dProperty`1[Microsoft.Exchange.Data.IPRange]”. Error: “The value ‘’ is already present in the collection.””
    At line:1 char:47
    + Get-Content .iplist.txt | foreach {$RecvConn. <<<< RemoteIPRanges += "$_"}
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

    Exception setting "RemoteIPRanges": "Cannot convert value "System.Object[]" to type "Microsoft.Exchange.Data.MultiValue
    dProperty`1[Microsoft.Exchange.Data.IPRange]". Error: "The value '' is already present in the collection.""
    At line:1 char:47
    + Get-Content .iplist.txt | foreach {$RecvConn. <<<< RemoteIPRanges += "$_"}
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

    Can someone assist ???

    1. Avatar photo
      Paul Cunningham

      The answer is in the error message. Two of the IP addresses you’re trying to add are “already present in the collection”.

      1. Liran Zamir

        Thanks, I managed.
        None of the IP addresses were already present. The trick for me to get it to work was to specify
        In the first line the full connector name (including the server name) instead of only the connector name.


      2. Rodney Ferretti

        I notice that if you have an error like “The value ‘’ is already present in the collection.””, the script stops.
        Anyone knows how can I make the script still running and putting the rest of the IPs to the receive connector even with some errors ?
        Tks in advance.

      3. Avatar photo
        Paul Cunningham

        Hi Rodney, I guess a bit of script logic to check for existing IP’s first would do the trick. I’ll see if I can come up with something.

  31. Jim M

    It looks like it’s an Active Directory thing. AD2000 has ~800 limit, and AD2003 has ~1300. I think we’re on a functional 2000 domain.

    All of these entries are for printers that scan and email. Maybe an easier way would be to make an authenticated receive connector and just change the printer settings to authenticate with a generic account. Sounds a little easier huh….

  32. Jim M

    I liked the script above but when I hit exactly 863 ip’s in a receive connector I can no longer add any more IPs. I receive the error below. Has anyone ran into this error? I get the same thing when adding an additional entry in the GUI as well. I’ve read it is a limitation of Active Directory.

    Set-ReceiveConnector : Active Directory operation failed on c15088dc3001.mydomain.
    com. This error is not retriable. Additional information: The administrative li
    mit for this request was exceeded.
    Active directory response: 00002024: SvcErr: DSID-02080490, problem 5008 (ADMIN
    _LIMIT_EXCEEDED), data -1112
    At line:1 char:32

    Is the only workaround adding another receive-connector? I am not in the position of adding a range, because it’s an anonymous POP3 Connector.

    1. Avatar photo
      Paul Cunningham

      Well having never added 863 IP’s to a Receive Connector I can’t say I’ve ever hit that limit 🙂

      I guess either add another connector so you can add more IP’s. Or try to make some or all of them authenticated connections instead so you don’t have to limit by IP address.

      One other (maybe not so good) idea would be to restrict the IP’s using a firewall rule instead, and just leave the Receive Connector open, but that would not be my ideal choice.

  33. Avatar photo
    Paul Cunningham

    Yee, I don’t have a code sample for it but I would imagine it would be as easy as wrapping up the example above into a loop.

    1. Erwin

      get-receiveconnector | where {$_.Name -like “*Default*”} | Set-ReceiveConnector -RemoteIPRanges (Get-Content .iplist.txt)

      1. Avatar photo
        Paul Cunningham

        That will modify multiple Receive Connectors but it will overwrite all of their existing remote IP addresses.

  34. Yee

    how do you add multiple IP addresses from a text file to multiple Hub Transport connectors?

Leave a Reply