Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

Search-Mailbox deleted all my data

$
0
0

Please can someone explain why this power shell code deleted all inbox items!!!!

The code should get today's data and subtract 6 months, this should leave the last 6 months of data in the users mailbox.

What happened was when we ran the code is removed all mailbox items and ignored the date range, even worse because this is a system command this bypasses the recover deleted items causing data loss.

Interested to hear peoples comments.

$from = (Get-date).addyears(-2).ToString("MM/dd/yyyy HH:mm")

$to   = (Get-date).addmonths(-6).ToString("MM/dd/yyyy HH:mm")

Get-Mailbox userABC | Search-Mailbox -SearchQuery {"Received:`"$from`"..`"$to`""} -TargetMailbox "administrator" -TargetFolder "SearchAndDeleteLog" -DeleteContent


Viewing all articles
Browse latest Browse all 7132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>