Select non-default receive connectors
Sometines you want to select all non-default receive connectors for further processing in PowerShell. The following simple example selects all receive connectors excluding the connectors using server name as part of the connector name.
When querying the receive connectors for a server you will get all configured connectors.
Get-ReceiveConnector -Server $Server | ft -AutoSize Identity Bindings Enabled -------- -------- ------- DEHVNEX1\Default DEHVNEX1 {0.0.0.0:2525, [::]:2525} True DEHVNEX1\Client Proxy DEHVNEX1 {[::]:465, 0.0.0.0:465} True DEHVNEX1\Default Frontend DEHVNEX1 {[::]:25, 0.0.0.0:25} True DEHVNEX1\Outbound Proxy Frontend DEHVNEX1 {[::]:717, 0.0.0.0:717} True DEHVNEX1\Client Frontend DEHVNEX1 {[::]:587, 0.0.0.0:587} True DEHVNEX1\Anonymous Relay {0.0.0.0:25} True DEHVNEX1\From Veruna-BER {0.0.0.0:25} True DEHVNEX1\APPS-Relay {0.0.0.0:25} True
The following PowerShell query excludes the receive connectors as mentioned.
$server='DEHVNEX1' Get-ReceiveConnector -Server $Server | ` ?{(([string]$_.Identity).Split('\')[1]) -notlike "*$($Server)*"} | ` ft -AutoSize Identity Bindings Enabled -------- -------- ------- DEHVNEX1\Anonymous Relay {0.0.0.0:25} True DEHVNEX1\From Veruna-BER {0.0.0.0:25} True DEHVNEX1\APPS-Relay {0.0.0.0:25} True
If you want to reuse the filtered output for further processing, simply store the output in a variable, e.g., $ReceiveConnectors.
$ReceiveConnectors=Get-ReceiveConnector -Server $Server | ` ?{(([string]$_.Identity).Split('\')[1]) -notlike "*$($Server)*"}
This is a basic example and should encourage you to extend it to fit your needs in your Exchange Server environment.
Enjoy Exchange Server.