I'm trying to use a param block in my PowerShell script to populate some variables, but I'm running into an issue with the New-ComplianceSearch command. It requires the search query to be in single quotes, which causes my variables to be interpreted as plain text instead of their actual values when the search is created in Purview. Here's the relevant part of my code:
param(
[Parameter(Mandatory)]
$SearchName,
[Parameter(Mandatory)]
$FromAddress,
[Parameter(Mandatory)]
$Subject
)
New-ComplianceSearch -Name "$SearchName" -ExchangeLocation all -ContentMatchQuery 'from:"$FromAddress" AND subject:"$Subject"'
1 Answer
You might want to try using `$($FromAddress)` and `$($Subject)` in the query. That way, the variables should be correctly evaluated when you run the command!
Related Questions
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically
[Centos] Delete All Files And Folders That Contain a String