Wednesday, April 6, 2011

Powershell multi-value attributes

Now and then you encounter that you must handle multivalued properties in Exchange Management Shell (EMS). This can be a little tricky of you don’t know how to do this.

I will give some examples to highlight different syntaxes you can use. I will use the attribute RemoteIPRanges on ReceiveConnector but examples can be used on any multi-value attribute.

Adding some IP ranges. This will overwrite every IP range already present.
Set-ReceiveConnector <Connector name> -RemoteIPRanges "", ""

List multivalued properties.
Get-ReceiveConnector <Connector name>).RemoteIPRanges

Adding additional IP. This is completed by first save the range array into $range variable. Adding values to the $range variable and then write the info in $range variable to the receiveconnector.

$range = (Get-ReceiveConnector <Connector name>).RemoteIPRanges

$range += ""

Set-ReceiveConnector <Connector name> -RemoteIPRanges $range

You can also remove entries from the array with the same method as adding.

$range -= ""

Because you have all entries in the $range variable you can do things like copy ranges from one connector to another one.

$range = (Get-ReceiveConnector <Connector name>).RemoteIPRanges

Set-ReceiveConnector <another Connector name> -RemoteIPRanges $range

1 comment:

  1. I came onto your blog and focus just slightly submits. Nice strategy for text. I'll be bookmarking straight away seize all of your rss.