I have a script that will read information from a CSV file and will delete emails in O365 using the search-mailbox with the delete content switch. I am getting different results and I think it is a problem with my query string. The email to delete is found using the email address, subject and the date and time sent. This should result in only one email found. What is happening is when I test the script the logs say more emails are found. I have output the query string using write-host then applied it manually to the search mailbox command and only get one result. I am struggling to figure out why I get different results.
#18-6-18 #Version 1.0 Initial Script write-host "`n" write-host "Welcome to the GDPR Erasure Tool Version 1.2 `n"
$ConnectToO365 = read-host "Press C to connect to O365 `n"
##This function converts the date and time into US and format it so that the search-Mailbox can use it. $dateTime = $date -split " " $USDSplit = $dateTime -split '/' $usd= $USDSplit+'/'+$USDSplit+'/'+$USDSplit $Output = $usd+'..'+$datetime