More Multi-valued Parameters in PowerShell (SourceTransportServers in Set-SendConnector)

In my first article on Multi-valued Parameters in PowerShell, I discussed a certain class of array parameters that Exchange 2007 uses many times – the [System.Object[]] (i.e., array of arbitrary elements) class for RemoteIpRanges.

Unfortunately, that isn’t the only multi-valued type used by PowerShell for Exchange Server 2007. There are actually quite a few of them.

Another type that comes up fairly often is SourceTransportServers. This is used by the Set-SendConnector cmdlet among others. It is a collection of a specific type of objects that Exchange 2007 refers to as ADobjectIDs.

An ADobjectID is actually quite similar to a System.DirectoryServices.DirectoryEntry – however, in comparison, this type has very few populated properties. The fact that the property list for ADobjectID is quite small indicates the reason why Exchange uses this type instead of System.DirectoryServices.DirectoryEntry – the population of a few types is much more efficient than the population of all the types present for a DirectoryEntry.

Populating and updating SourceTransportServers is a common idea, especially when you are using provisioning scripts to completely deploy new servers. Here is an example of PowerShell code that you can use to do this:

$newhub = Get-ExchangeServer "newhubserver"
$adobject = New-Object Microsoft.Exchange.Data.Directory.ADobjectID $newhub.distinguishedName

$a = Get-SendConnector "Internet Email"
$a.SourceTransportServers.Add($adobject)

$a | Set-SendConnector

Until next time…

If there are things you would like to see written about, please let me know!


Follow me on twitter: @EssentialExch

Leave a Reply

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