Quantcast
Viewing all articles
Browse latest Browse all 8820

Powershell script to delete emails from mailbox older than 90 days

Hello,

I need to delete all messages that are older than 90 days from a mailbox which includes inbox and all subfolders.  So this is what I have.  I don't have a test environment, so will need to run this in Prod and schedule it to run daily.   Even though it looks straighforward, it is doing a delete, so am a litte paranoid :).  Can you guys please verify if it looks ok?

$daysback = (Get-Date).adddays(-90)

Search-Mailbox abc@abc.com –SearchQuery “Received:< $($daysback)” –DeleteContent

Thanks


Viewing all articles
Browse latest Browse all 8820

Trending Articles



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