validate Email address


posted by Tobias Weltner
11-26-2008

Downloads: 312
File size: 260 B
Views: 1,919

Embed
validate Email address
  1. function isEmailAddress($object) {  
  2.     ($object -as [System.Net.Mail.MailAddress]).Address -eq $object -and $object -ne $null 
  3.  
  4. isEmailAddress "test" 
  5. isEmailAddress "tobias@powershell.com" 
  6. IsEmailAddress "test.name@somewhere.com" 
  7. isEmailAddress $null 
uses the System.Net.Mail.MailAddress type to check whether a given string is a valid email address. isEmailAddress returns $true for all valid email addresses, otherwise $false.
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.