Powershell – looping Get-ReceiveConnector to grab multiple receive connectors

exchangepowershell

This is on a Windows 2008R2 server running Exchange2010.

I would like to use powershell and "Get-ReceiveConnector" to grab information from about 20 configured receive connectors. Ultimately we are migrating to a different exchange server, so my goal is to export them to text and then import them later.

This article: http://terenceluk.blogspot.com/2010/11/how-do-i-exportimport-exchange-20072010.html gives some good info on pulling the data from individual receive connectors, but I'd like to use foreach or something similar to loop through all receive connectors on that particular server – I'm just not sure how to do it.

Thanks!

Best Answer

This isn't too tough, it's Powershell 101 really. If you're going to be doing a bunch of Exchange work, you'll definitely need to learn PS front to back.

$conns = Get-ReceiveConnector
foreach ($conn in $conns) {$conn.name }

If you need to limit it to only a specific server, do this

$conns = Get-ReceiveConnector -server MyServerName
foreach ($conn in $conns) {$conn.name }

In the examples, above, I'm just listing the connector name in the body of the loop - the statement in between the curly brackets. You would replace that with whatever it is that you want to do with each connector.