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
34 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
  • 2
3 Comments
 
LVL 69

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 69

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

770 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