0 votes

Hello!

some of our users have multiple email addresses and also have different variations of their name and perhaps their assistants name within the SMTP addresses.
for instance bob cook has the following emails: bcook@abc.com, cookb@abc.com, bcook@domain.com, bobcook@abc.com, tmarie@abc.com.

I've created a task that says "if the 'email proxy addresses' property contains '@abc.com', then
modify mailbox setting for the user: modify email addresses (remove 'smtp:%mailnickname%@abc.com')

which obviously works great if the mailnickname matches...but not certain how to remove the others.

Please let me know how I can remove all instances of email addresses that contain @abc.com from their SMTP.

Thanks in advance!

by (1.7k points)
0

can someone pls reply?

I hope my subject isn't confusing

1 Answer

0 votes
by (216k points)
selected by
Best answer

Hello,

To do this, you will need to use a PowerShell script. Have a look at the following script from our Script Repository that will do the job: Remove values of a multivalued property using regular expressions.

Parameters that you need to specify in the script:

  1. $property: "proxyAddresses";
  2. $regex: "smtp:\w+@abc\.com"

To add the script to your Scheduled Task, use the Run a program or PowerShell script action.

0

Wow - a script repository??? totally awesome!

THANK YOU!

0

so I tested and it seemed to only get rid of all the email addresses specified, but not the primary SMTP which has the same domain.
perhaps I would have to include my above command to the task to remove?

EDIT - yep, adding the second task takes care of the primary SMTP.
ultimately our goal is to remove that domain from our farm, hence the removal.

0

Hi again,

would I be able to use that script to remove a forwarding address from the accounts?

so some of the accts have abc domain and some have emails being forward elsewhere. I'd like to remove the multiple smtps with the script, but also uncheck the forwarded option.

0

Hello,

Removing primary addresses

We've made a script in such a way that it would not remove the primary address from a mailbox, and this was done on purpose. Removing a primary address is not a good idea at all, because if you remove the primary SMTP address from a user, the mailbox becomes corrupted.

Since you are going to remove that email domain completely, we can suggest that for those mailboxes that have the primary address in the domain the script would replace the primary addresses to a certain default address, for example, in the format %mailNickName%@newmaildomain.com, where newmaildomain.com is some default mail domain for such mailboxes.

Removing Forward To

Do you want to remove the forwarding address only from those mailboxes that have any addresses in the abc.com domain or from all mailboxes? Also, should the script remove the forwarding address only if it set to the abc.com domain or not? Could you provide as much detail as possible?

0

Thank you for the explanation, that would definitely work.

Regarding the forward to -
the forward addresses contains @abc.com, so it looks like xx@g.abc.com.
we'd like to say for all mailboxes that contains an abc.com SMTP and have a forward that contains xx@g.abc.com, remove the SMTP and uncheck/remove the forward option. (unchecking would suffice as its just a contact).

if the user has the abc SMTP address but no forward, remove the SMTP.

I hope this is clear.

thanks

0

Hello,

OK, it's clear. We've assigned our script guys to the task and will update you as soon as they come up with something.

0

Hello -

any update on this?

Thanks

0

Hello,

To achieve what you need, you'll need to add the following 3 actions to your task:

  • Change the primary e-mail address if it is in e-mail domain abc.com
    To do this:

    1. Add the Modify Exchange properties action.
    2. Click the Exchange Properties button.
    3. On the E-Mail Addresses tab, activate the Modify e-mail addresses option.
    4. Make sure that the Replace existing addresses with the ones specified option is not enabled.
    5. Click Add Modification.
    6. Select Add Address, and then SMTP Address.
    7. Specify a template for the new primary address, for example, %mailNickName%@newmaildomain.com.
    8. Click OK
    9. Enable the Set as reply option.
    10. Enable the 1st check-box for the Automatically update e-mail addresses based on e-mail address policy option.
    11. Click OK 3 times.
    12. Double-click Always.
    13. Select if <property> <relation> <value>.
    14. Specify If Email matches regexp.
    15. Specify the following regular expression: \w+@abc\.com.
    16. Click OK
  • Remove all e-mail addresses in e-mail domain abc.com

    1. Click the Add action to a new set link.

    2. Select the Run a program or PowerShell script action and paste the following script from our Script Repository: Remove values of a multivalued property using regular expressions.

    3. Specify the following parameters in the script:

       - **$property:** "proxyAddresses";
       - **$regex:** "smtp:\\w+@abc\\.com"
    4. Enter a short description for the script and click OK.

  • Remove mail forwarding if the email of the forwarding recipient is in e-mail domain abc.com

    1. Right-click the action you've just added and select Add new Action.
    2. Select the Run a program or PowerShell script action and paste the following script from our Script Repository: Disable mail forwarding if forwarding address matches regular expression.
    3. Enter a short description for the script and click OK.

    You should receive something like this:

0

thank you. I will test this.

0

hi,

i'd like to run this on contacts, as it seems contacts have abc domain.
I set up a another job to run against contact object, but nothing happened. am I using it correctly or this can't be applied to contact objects?

0

Hello,

We've re-checked this functionality on contacts, and in our environment it works perfectly except for the script that disables forwarding, which is natural, because you cannot set a forwarding recipient for a contact.

Can you post here or send us a screenshot of the task that you've created for contacts and also a contact that you've tested with in LDIF format? For information on how to export AD objects to LDIF, see Exporting Directory Objects. If you are not willing to post the information here, you can send it to our support email (support[at]adaxes.com).

0

thank you. I've sent via email instead...just easier to post pics etc.

0

It appears that the regular expressions we used didn't take into account special characters, and you have hyphens in the email addresses of the contacts. To correct the issue, use the following regular expression in the script an in the condition:
^smtp:[a-zA-Z0-9_.%%\-\+]+@abc\.com$

0

hello - I am getting invalid character for expression command.

0

Sorry, our mistake. You need to use the same regular expression as you used for the script:
^smtp:[a-zA-Z0-9_.%%\-\+]+@abc\.com$

We apologize for the inconvenience.

0

thanks!

just sent you something else.
it seems to remove all smtp addresses even ones that do not mention abc.com.
we only want to get rid of abc.com and nothing else.

0

any luck?

0

hi-- just checking in to see if theres a reason the script removes all addresses and not the one specified.

thanks

0

Hello,

We've forwarded all the available information to our script guys. They are checking the script, but no luck so far. We'll update you as soon as they come up with something.

0

ok, thanks

Related questions

0 votes
1 answer

Hallo @All, I'm working in an cloud environment with many tenants and every tenat has the same organizational unit structure. Now I want to add a security rule that deny access to ... *,DC=contoso,dc=msft,dc=com I hope someone has a hint for me. Thanks Arne

asked Oct 26, 2015 by ATiedemann (360 points)
0 votes
1 answer

As part of business rules etc we are able to add\remove accounts to groups. It would be nice if this feature could be extended to allow for wildcard ... multiple groups that meet the matching condition (without resorting to PowerShell script actions). Thanks

asked Aug 5, 2014 by firegoblin (1.6k points)
0 votes
1 answer

I'm trying to modify this report to only output results where employeeType equals the values below. It reports fine. I would also like to include where employeeType ... = "(&amp;" + $filterUsers + $filterPasswordLastSet + $customAttribute + $enabledUser + ")"

asked Mar 28 by tromanko (180 points)
0 votes
1 answer

Hello team, our users are created by HR system into AD and have the start date as string in extensionAttribute2 with a prefix (like "startdate_2024-01-02"). Sometimes the user ... "Employee" Do you have a script in place to achieve this? Thanks in advance.

asked Mar 26 by wintec01 (1.1k points)
0 votes
1 answer

I have made a deprovision custom command. I cannot change the attribute directReports, so was thinking - i could take the people in the directReports field of the manager ... (and its subordinates) that im running the deprovision custom command from. Any tips?

asked Mar 21 by EdgarsABG (50 points)
3,346 questions
3,047 answers
7,782 comments
544,986 users