Reputation: 5
I'm having an issue when trying to complete my script.
I'm trying to create a rule for couple of users: (if message arrives from (x), move to Inbox). This is the script I wrote:
$names = @{"[email protected]","[email protected]"}
foreach($name in $names){
Write-Host "Moving the message for $name"
new-inboxrule -Name "MoveFromMailchimp" -Mailbox $name -MoveToFolder
"$name:\Inbox" -From "senderEmailAddress" -StopProcessingRules: $false
}
However it throws an error upon $name:\Inbox, saying it does not want to take ":".
Does anyone have any ideas?
Upvotes: 0
Views: 148
Reputation: 2434
You need to escape your variable in the string.
Try:
"$($name):\Inbox"
Upvotes: 1