Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 57
  • Last Modified:

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

If I have a semicolon delimited list of emails like:


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:


Thanks for your help!
  • 2
1 Solution
QlemoC++ DeveloperCommented:
Is the colon correct? Shouldn't it be
? 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

HankinaterAuthor Commented:
That's it - that's perfect!

Thanks Qlemo!
QlemoC++ DeveloperCommented:
It's probably too simple, but might work for you. Usually I would add some more checks.

Featured Post

Who's Defending Your Organization from Threats?

Protecting against advanced threats requires an IT dream team – a well-oiled machine of people and solutions working together to defend your organization. Download our resource kit today to learn more about the tools you need to build you IT Dream Team!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now