Introduction to PowerShell Updating

Managing an Exchange Server environment efficiently is crucial for ensuring communication within an organization. One essential task is updating the send connector to include new servers when new servers are added and old servers are removed.

Updating the Send Connector with PowerShell

If you are an MSP that utilizes many send connectors for your customers, manually updating these is a long process if you used the Exchange Admin Center (EAC). I put together this PowerShell script below that reads a text file and defines all the send connectors you want to target to update and then allows you to add in the servers within the PowerShell script itself.

These two sections need to be updated in the PowerShell script:

  1. $filePath (This is the text file with the send connector names in, one item per line)
  2. $serversToAdd (List all the servers you want added to the send connector, an example of multiple servers would be “Server1″,”Server2″,”Server3”)

Here is the PowerShell script you can use:

#Load the Exchange 2016/2019 SnapIn
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn
# Path to the text file
$filePath = "C:\Installs\SendConnectors.txt"
# Define the servers to add
$serversToAdd = @("Server1")
# Convert all server names to uppercase
$serversToAdd = $serversToAdd | ForEach-Object { $_.ToUpper() }
# Read the file line by line
$sendConnectors = Get-Content -Path $filePath
foreach ($sendConnectorName in $sendConnectors) {
    # Get the existing send connector
    $sendConnector = Get-SendConnector -Identity $sendConnectorName
    # Get the current list of source transport servers and convert to uppercase strings
    $currentServers = $sendConnector.SourceTransportServers | ForEach-Object { $_.ToString().ToUpper() }
    # Find the servers that are not already in the current list
    $serversToActuallyAdd = $serversToAdd | Where-Object { $_ -notin $currentServers }
    if ($serversToActuallyAdd.Count -gt 0) {
        # Combine the existing servers with the new ones
        $updatedServers = $currentServers + $serversToActuallyAdd
        # Update the send connector with the combined server list
        Set-SendConnector -Identity $sendConnectorName -SourceTransportServers $updatedServers
        Write-Output "Updated $sendConnectorName with new servers: $serversToActuallyAdd"
    } else {
        Write-Output "No new servers to add for $sendConnectorName"
    }
}
Write-Output "Send connectors updated successfully."

Discover more from COLLABORATION PRO

Subscribe now to keep reading and get access to the full archive.

Continue reading