Quantcast
Viewing all articles
Browse latest Browse all 8719

-Searchquery syntax

Can someone please explain to me what I am doing wrong here?  I cannot get this to work  If I take out the received:>$date and only leave subject:$subject in my searchquery it works fine, otherwise I get no results.  I've tried every combination of quotes and double quotes brackets etc but just cant seem to make this work.

$subject = Read-Host "Enter subject of email to delete:"
$mb = Get-Content C:\users2.txt
$date = (Get-date).AddDays(-1)
Search-Mailbox -Identity $mb -SearchQuery {Received:>$date AND subject:$subject} -DeleteContent -Force

Thank you.



Viewing all articles
Browse latest Browse all 8719

Trending Articles