I just started to learn how to write script in powershell. I need to delete all old messages in outlook before 2015 in different emails using powershell. Can you please help me with that. This is what I have for now.
$DT = (Get-Date).AddMonths(-96).ToString("MM/dd/yyyy")
Search-Mailbox -Identity usermailbox - SearchQuery '(Received:MM/dd/yyyy)' - DeleteContent -Force
I'm not sure that I'm doing it right.