Link to home
Start Free TrialLog in
Avatar of Garry Shape
Garry ShapeFlag for United States of America

asked on

Use Powershell Replace e-mail address in ForwardTo address domain names?

So there are a few dozen inbox rules for a mailbox that have the right user (such as John.Doe, but the wrong domain (@wrongdomain.com).
So I'm trying to get John.Doe@wrongdomain.com set to JohnDoe@correctdomain.com in the inbox rule.

I can get all the rules:
$AllFwdRules = Get-InboxRule -Mailbox "Mailbox" | ? {$_.ForwardTo -like "wrongdomain.com"}.
If I do: $AllFwdRules | select -first 1 | select ForwardTo
I see a couple addresses there in this output:

ForwardTo : {"John Doe" [SMTP:john.doe@wrongdomain.com], "Pat Doe" [SMTP:Pat.Doe@wrongdomain.com]}

For the Set-InboxRule paramters, it tells -ForwardTo can take an e-mail address.
So what I'm trying to do is just get the wrong address, replace the domain with @correctdomain.com, then set it (or multiple if so) for the ForwardTo property back on the rule.
Does anyone know how this can be done?
ASKER CERTIFIED SOLUTION
Avatar of Thomas U
Thomas U
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
and by the way, my alterings are quite hacky, but if it works ;)
Avatar of Garry Shape

ASKER

Holy wow, that's amazing. Thank you so much.