Bigbio2002
Bigbio2002

Reputation: 163

How do I add double-quotes to each item in my input string?

I'm trying to concatenate a string into an object, with the format of "[email protected],[email protected],[email protected]". However, the parameter is expecting every value in the string to be surrounded by quotes, such as ""[email protected]","[email protected]","[email protected]"". The error is "Property validation failed", and it is expecting a System.String. How do I go about resolving this?

The exact lines of code are...

$existingconfig = get-mailboxjunkemailconfiguration $_.address
$existingconfig.trustedsendersanddomains += $_.approved_senders

where $_.approved_senders = "[email protected],[email protected],[email protected]"

Upvotes: 1

Views: 913

Answers (1)

CitizenRon
CitizenRon

Reputation: 895

Using Get-MailboxJunkEmailConfiguration -Identity BSmith | Get-Memeber shows that the TrustedSendersAndDomains property is a multiValuedProperty string, i.e. an Array. You can try changing the value of the $_.approved_senders into an array with -Split

$existingconfig = get-mailboxjunkemailconfiguration $_.address
$existingconfig.trustedsendersanddomains += ($_.approved_senders -Split ",")

Upvotes: 1

Related Questions