>Missing closing '}' in statement block
As it said, there missing a "}" for ForEach function.
If the response is helpful, please click "Accept Answer" and upvote it.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi i am using the below syntax to delete an email from 3 user mailboxes with subject Test've Test-abcdef msggg, i have csv file in the below format. i am getting syntax error.
Name
user1@Company portal .com
user2@Company portal .com
user3@Company portal .com
$mailboxes = Import-Csv C:/temp/mailboxes.csv
ForEach ($mailbox in $mailboxes){
New-ComplianceSearch -Name $mailbox.name -ExchangeLocation $mailbox.name -ContentMatchQuery '(Received:08/18/2020 00:00..08/20/2020 23:59) AND (Subject:"Test've Test-abcdef msggg") AND (From:"anon@USER ")'
Start-ComplianceSearch -Identity $mailbox.name
}
New-ComplianceSearch -Name $mailbox.name, is it possible to give any name for compliance search, if i use $mailbox.name will the name of compliancesearch be user1@Company portal .comuser2@Company portal .comuser3@Company portal .com
>Missing closing '}' in statement block
As it said, there missing a "}" for ForEach function.
If the response is helpful, please click "Accept Answer" and upvote it.
Hi
Maybe instead of Import-Csv C:/temp/mailboxes.csv, change the / with \ :
Import-Csv "C:\temp\mailboxes.csv"
>is it possible to give any name for compliance search
You need to modify the source file as below:
Then modify this part in that script:
Before running script each time, you also need to modify the SearchName(such as from S1,2,3 to a1,2,3), otherwise, it will still conflict(error like: this Compliance Search name exists)
If the response is helpful, please click "Accept Answer" and upvote it.