Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
53 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 71

Accepted Solution

by:
Qlemo earned 2000 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 71

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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
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.
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 anti-spam), the admin…
Screencast - Getting to Know the Pipeline

886 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