Monthly Archives: July 2012

Copy Receive Connector Settings

I came across a particularly useful set of commands today while needing to enter a huge list of allowed IP’s for a receive connector in Exchange on multiple servers.  This comes in particularly handy when needing to copy allowed IP addresses from one connector to another (usually on multiple servers) for the purpose of say anonymous relaying.

$connector = Get-ReceiveConnector “ServerName\ConnectorName

Set-ReceiveConnector “ServerName\ConnectorName” –RemoteIPRanges $connector.RemoteIPRanges

Very simple set of commands used frequently in Powershell, just thought this one was particularly useful as we have additional addresses to add and subtract from anonymous relaying connectors on mutliple servers frequently.

Advertisements

Remove Old Email Addresses from Exchange 2010

If you’ve ever changed an email address policy in Exchange, you are aware that old addresses from previous policies are not deleted.  This is by design and intentional but what if you made a mistake in your policy and need to remove hundreds of invalid addresses from accounts.  For instance… you created a policy for [firstinitial.lastname@domainname.org] when you really meant to set an underscore  as a separator instead of the period.

The following script will use a regular expression to find all email addresses containing periods between firstinitial and lastname then remove them.

$allmailboxes = get-mailbox
$allmailboxes |% {$a = $_.emailaddresses; $b = $_.emailaddresses; foreach ($e in $a) {if ($e.tostring() -match “[a-z]+\.[a-z]+@domainname.org”) {$b -= $e;}}$_ | set-mailbox -emailaddresses $b}

By simply editing the regular expression in this script, you can search for all kinds of different combinations of addresses and remove them from your users mailboxes.