Adding IP to multiple relay connectors

Adding IP to multiple relay connectors:

A customer has 5 Exchange 2013 servers. Each have an interal relay connector and an external relay connector.

Everytime e.g. a new scanner or a server needs to relay email, the IP has to be added to eigther the internal og external relay connectors.

Instead of adding the IP to five connectors each time, this script will do it for you.

It is very simple to expand this script with more choises and connectors.

Adding IP to multiple relay connectors
Adding IP to multiple relay connectors

I found the “Multiple Choise Menu” here on TechNet
I modified it so it could be used to adding IPs on the connectors.

Here is the script:

$newip = read-host 'Enter IP'
do {
write-host ""
write-host "1 - Relay_Internal"
write-host "2 - Relay_External"
write-host ""
write-host -nonewline "Choose your connector: "

$choice = read-host

write-host ""

$ok = $choice -match '^[12x]+$'

if ( -not $ok) { write-host "Invalid selection" }
} until ( $ok )

switch -Regex ( $choice ) {
"1"
{
$a = Get-ReceiveConnector exch01\relay_internal
$b = Get-ReceiveConnector exch02\relay_internal
$c = Get-ReceiveConnector exch03\relay_internal
$d = Get-ReceiveConnector exch04\relay_internal
$e = Get-ReceiveConnector exch05\relay_internal
}

"2"
{
$a = Get-ReceiveConnector exch01\relay_eksternal
$b = Get-ReceiveConnector exch02\relay_eksternal
$c = Get-ReceiveConnector exch03\relay_eksternal
$d = Get-ReceiveConnector exch04\relay_eksternal
$e = Get-ReceiveConnector exch05\relay_eksternal
}
}

$a.remoteipranges += $newip

Set-ReceiveConnector $a -RemoteIPRanges $a.remoteipranges
Set-ReceiveConnector $b -RemoteIPRanges $a.remoteipranges
Set-ReceiveConnector $c -RemoteIPRanges $a.remoteipranges
Set-ReceiveConnector $d -RemoteIPRanges $a.remoteipranges
Set-ReceiveConnector $e -RemoteIPRanges $a.remoteipranges

Thanks for reading

No Comments

Leave a Reply

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

Exchange Tips
Disappearing restore request

Disappearing restore request. When your restored stuff just disappear in front of you. We are running a hybrid with Exchange 2016. The users have an on-prem mailbox and an archive in Exchange Online. A employee left the company, got married and then came back. Service Desk decided to give her …

Exchange Tips
2
Hybrid Configuration Wizard mailflow problem

Recently the Exchange hybrid team released the new “stand alone” hybrid wizard called “Microsoft Office 365 Hybrid Configuration Wizard” or HCW. Read the post on the Exchange Team Blog about the new Hybrid Configuration Wizard here¬†http://blogs.technet.com/b/exchange/archive/2015/09/04/introducing-the-microsoft-office-365-hybrid-configuration-wizard.aspx Today I decided to try it out in my lab to prepare myself for …

Exchange Tips
How to phase out Exchange archive mailboxes

A customer wants to phase out their Exchange archive mailboxes. There are no reason for them to keep them. Back then they were told about cheap storage and large ost files, but all their data is placed on the same SAN and they are soon using Outlook 2013. They have …