Forum Discussion
creation of exchange receive connector from csv
I'm trying to create a script that should create an exchange receive connector from a CSV file that contains the list of the connectors to create as well as some properties.
The problem is not the creation of the connector, which we can create from the csv, but the "remoteiprange" properties that throw an error.
The csv file has this format
"Name","Bindings","DeliveryStatusNotificationEnabled","AdminDisplayName","RemoteIPRanges","PermissionGroups"
"TestConn","0.0.0.0:25","True","","192.168.101.0/23 192.168.102.0/23","AnonymousUsers, ExchangeServers, Custom"
So we read all the parameters from the file and try to create the new connector passing them to the command but the error we get is
New-ReceiveConnector : Cannot bind parameter 'RemoteIPRanges'. Cannot convert value "192.168.101.0/23,192.168.102.0/23" to type "Microsoft.Exchange.Data.IPRange". Error: "The format of the IP address
192.168.101.0/23,192.168.102.0 is invalid. Example of a valid IP address: 192.168.1.10"
- LainRobertsonSilver Contributor
Hi, Stefano.
The sample data and the values shown in the error aren't the same, so I'm going to work from the data that features in the error (notably, the source data doesn't contain a comma between the ranges while in the error it does).
The issue, then, is that the value of "192.168.101.0/23,192.168.102.0/23" is being passed in as a single string on the call to New-ReceiveConnector when what is required is an array. As a single string, the value is invalid, hence the error.
You haven't provided your command/script so I can only offer a general example for splitting the string.
# Assumption: That we're inside of a foreach loop where the current CSV row is contained in $entry. $ipRanges = $entry.remoteIpRange.Split(","); # Partial command only showing the RemoteIPRanges parameter. New-ReceiveConnector -RemoteIPRanges $ipRanges;
Cheers,
Lain