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
28 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 68

Accepted Solution

by:
Qlemo earned 500 total points
Comment Utility
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
Comment Utility
That's it - that's perfect!

Thanks Qlemo!
0
 
LVL 68

Expert Comment

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Synchronize a new Active Directory domain with an existing Office 365 tenant
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now