Garry Shape
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?
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
and by the way, my alterings are quite hacky, but if it works ;)
ASKER
Holy wow, that's amazing. Thank you so much.