Skip to content
This repository was archived by the owner on Sep 17, 2023. It is now read-only.

Update Copy-ReceiveConnector.ps1 #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions Copy-ReceiveConnector.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE
RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.

Version 1.6, 2018-03-26
Version 1.6, 2019-10-08

Please send ideas, comments and suggestions to support@granikos.eu

Expand All @@ -21,9 +21,10 @@

.NOTES
Requirements
- Windows Server 2008 R2 SP1, Windows Server 2012 or Windows Server 2012 R2
- Windows Server 2008 R2 SP1, Windows Server 2012, Windows Server 2012 R2, or Windows Server 2019
- Exchange Server 2007/2010
- Exchange Server 2013/2016
- Exchange Server 2019

Revision History
-------- -----------------------------------------------------------------------
Expand All @@ -35,6 +36,7 @@
1.41 Minor fixes and update for Exchange 2016
1.5 Issue #2 fixed
1.6 Issue #3 fixed
1.6.1 Added -FqdnOverride and -FqdnAuthFix

.PARAMETER ConnectorName
Name of the connector the new IP addresses should be added to
Expand Down Expand Up @@ -62,6 +64,13 @@

.PARAMETER ViewEntireForest
View entire Active Directory forest

.PARAMETER FqdnOverride
Overrides the old FQDN value.

.PARAMETER FqdnAuthFix
If the AuthMechanism has the flag ExchangeServer, this replaces $FqdnOverride with $TargetServer.


.EXAMPLE
Copy Exchange 2013/2016 receive connector nikos-one-RC2 from server MBX01 to server MBX2
Expand All @@ -88,7 +97,9 @@ param(
[switch] $CopyPermissions,
[switch] $MoveToFrontend,
[switch] $ResetBindings,
[switch] $ViewEntireForest
[switch] $ViewEntireForest,
[string] $FqdnOverride,
[switch] $FqdnAuthFix
)

# Set-StrictMode -Version Latest
Expand Down Expand Up @@ -119,6 +130,7 @@ function Copy-ToServer {
param(
[string]$TargetServerName = ''
)


if ($TargetServerName -ne '') {

Expand Down Expand Up @@ -149,6 +161,10 @@ function Copy-ToServer {
$sourceRC.Bindings = '0.0.0.0:25'
}

if($FqdnAuthFix -and $sourceRC.AuthMechanism.HasFlag([Microsoft.Exchange.Data.Directory.SystemConfiguration.AuthMechanisms]::ExchangeServer)) {
$FqdnOverride = $TargetServerName
}

# create new Receive Connector
New-ReceiveConnector -Name $sourceRC.Name `
-TransportRole $sourceRC.TransportRole `
Expand Down Expand Up @@ -189,7 +205,7 @@ function Copy-ToServer {
-EnhancedStatusCodesEnabled $sourceRC.EnhancedStatusCodesEnabled `
-Server $TargetServerName `
-AuthMechanism $sourceRC.AuthMechanism `
-Fqdn $sourceRC.Fqdn
-Fqdn @($sourceRC.Fqdn, $FqdnOverride)[!!($FqdnOverride -ne $null)]

if($CopyPermissions) {
# fetch non inherited permissons from source connector
Expand Down Expand Up @@ -222,6 +238,10 @@ function Copy-ToServer {
$sourceRC.PermissionGroups = $temp
}

if($FqdnAuthFix -and $sourceRC.AuthMechanism.HasFlag([Microsoft.Exchange.Data.Directory.SystemConfiguration.AuthMechanisms]::ExchangeServer)) {
$FqdnOverride = $TargetServerName
}

Get-ReceiveConnector "$($TargetServerName)\$($sourceRC.Name)" | Set-ReceiveConnector `
-RemoteIPRanges $sourceRC.RemoteIPRanges `
-Banner $sourceRC.Banner `
Expand Down Expand Up @@ -258,7 +278,7 @@ function Copy-ToServer {
-TarpitInterval $sourceRC.TarpitInterval `
-EnhancedStatusCodesEnabled $sourceRC.EnhancedStatusCodesEnabled `
-AuthMechanism $sourceRC.AuthMechanism `
-Fqdn $sourceRC.Fqdn
-Fqdn @($sourceRC.Fqdn, $FqdnOverride)[!!($FqdnOverride -ne $null)]
# -Bindings $targetRC.Bindings `
# -TransportRole $sourceRC.TransportRole `

Expand Down Expand Up @@ -322,4 +342,4 @@ elseif($TargetServer -ne ''){
elseif($CopyToAllOther){
# Copy to all other Exchange 2013/2016 servers
Copy-ToAllServers
}
}