If I've interpreted your problem correctly, this should result in (mostly) legitimate SMTP addresses:
# Assuming no quoted strings are used in the addresses
# and no comments are used in the addresses
# and no "international" characters are used in the addresses
# domain isn't expressed as an IP address "[xxx.xxx.xxx.xxx]"
# THESE are what's valid in a SMTP address. Note that the range is INVERTED by the "^" at the beginning
$InvertedValidCharactersRange = "[^A-Za-z0-9!#$%&'*+-/=?^_``{|}~.(),:;<>@[\]-]+"
Import-Csv c:\Junk\BadIdea.csv -Encoding UTF8 |
ForEach-Object{
$_.Value -replace $InvertedValidCharactersRange, "" # remove everything that's NOT a valid character
}
NOTE: There is no attempt to actually validate the SMTP address. This is purely a character deletion bit of code!