Reputation: 93
How do I remove SMTP: from this statement, I want to parse this from the returning email address I have tried several methods and it always makes the entire field return blank.
@{Name = "PrimaryEmail"; Expression = { $_.ProxyAddresses.Where( { $_.StartsWith( 'SMTP:') } ) } }
Upvotes: 0
Views: 321
Reputation: 25001
You can use the -creplace
operator for this.
@{ Name = "PrimaryEmail"
Expression = { $_.ProxyAddresses.Where( { $_.StartsWith( 'SMTP:') } ) -creplace '^SMTP:'}
}
-creplace
is a case-sensitive version of replace
. It works with array or string output. ^
matches the beginning of the current string. SMTP:
is a literal match.
Upvotes: 2