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
47 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
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…

615 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