Remove multiple secondary addresses

mara2021 1,101 Reputation points
2023-07-15T14:14:44.52+00:00

I am using the following script to remove an old secondary address. It is working fine. I would like to include 6 more old addresses (oldsmtp2.com, oldsmtp3.com, oldsmtp4.com, etc.) in this script to be remove. Would someone mind showing me how to do this? Thank you.

User's image

Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,793 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 113.8K Reputation points MVP
    2023-07-15T15:55:26.0333333+00:00

    Probably the easiest way would be to use a regex, something like this:

    $address.SmtpAddress -notmatch "oldsmtp1.com|oldsmtp2.com|oldsmtp3.com|oldsmtp4.com"

    This should match any addresses not ending with any of the listed domains.

    0 comments No comments

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.