Solved

PowerShell how to take a list of email recipients and validate whether it is a valid email address.

Posted on 2016-08-04
3
44 Views
Last Modified: 2016-08-08
If I have a semicolon delimited list of emails like:


OCRequiredInvitees@emaildomain.com;SAPEngineering:hosting@emaildomain.com

and I want to verify that each member in the list has "@emaildomain.com", how do I do that and put it back together so that it looks like this, in this case adding the email domain to SAPEngineering:

OCRequiredInvitees@emaildomain.com;SAPEngineering@emaildomain.com:hosting@emaildomain.com

Thanks for your help!
0
Comment
Question by:Hankinater
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 70

Accepted Solution

by:
Qlemo earned 500 total points
ID: 41742953
Is the colon correct? Shouldn't it be
  OCRequiredInvitees@emaildomain.com;SAPEngineering;hosting@emaildomain.com
? Assuming I'm correct, you would run something like
('OCRequiredInvitees@emaildomain.com;SAPEngineering;hosting@emaildomain.com' -split ';' | % {
  if ($_ -notmatch '.*@emaildomain.com') { $_ += '@emaildomain.com' }
  $_
}) -join ';'

Open in new window

0
 
LVL 2

Author Comment

by:Hankinater
ID: 41743106
That's it - that's perfect!

Thanks Qlemo!
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 41743218
It's probably too simple, but might work for you. Usually I would add some more checks.
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help you understand what HashTables are and how to use them in PowerShell.
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question