«

»

Nov 01

Print this Post

Add Allowed IP/Range to All Send Connectors

If you have Recieve connectors spread across multiple Exchange servers, this can help to add allowed senders to all of them at once.

AddAllowedRelay
AddAllowedRelay
AddAllowedRelay.zip
Version: 1
462.0 B
3 Downloads
Details

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010, Microsoft.Exchange.Management.PowerShell.Setup , Microsoft.Exchange.Management.Powershell.Support

# Create an Array of IP addresses you want to allow. You can use any format allowed by send connectors here to specify individual IPs or Ranges
$newIP = @(“x.x.x.x”)

# Replace “*SMTP Relay” with something that matches the naming of your SMTP relay receive connectors across all servers
# Get all the receive connectors that match your name
$connectors = Get-ReceiveConnector | WHERE Identity -Like “*SMTP Relay*”

# Set up a variable to store existing permissions
$remoteRanges = @()

### Loop Through Each IP address ###
foreach($ip in $newIP){

### Loop through each connector and build an array of the remote IPs/Ranges allowed ###
foreach($connector in $connectors){
foreach($remoteRange in $connector.RemoteIPRanges){
if(!($remoteRanges.Contains($remoteRange))){ $remoteRanges += $remoteRange }
}
}
### ###

### Check if the IP/Range you are adding is already there ###
if(!($remoteRanges.Contains($ip))){
$remoteRanges += $ip

### Add the new IP/Range to each connector. ###
foreach($connector in $connectors){
write-host “Adding $ip to $connector”
Set-ReceiveConnector $connector -RemoteIPRanges $remoteRanges
}
### ###
}
### ###
}
### ###

Permanent link to this article: https://www1.wperry.net/code/add-allowed-ip-range-to-all-send-connectors/

Leave a Reply

Your email address will not be published. Required fields are marked *