retention question

Hello Experts,

I have a client who is looking to change the default retention settings for deleted items and deleted mailboxes from the default values 14 and 30 to 365 days each one. see screenshot attached for details

Since I have 50 databases, with different names, I wonder if you can provide a PowerShell cmdlet to automate this task, instead of performing manually this task from EAC. so given a CSV input file, with the database names, can we change these settings for all the databases within the file at once?

Can you please also respond following questions?

what service should be restarted on each mailbox after changing these settings?

What is the service impact of this change?

Thanks in advance
Jerry SeinfieldAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Amit KumarCommented:
If you want to change for all then use below powershell:

get-mailboxdatabase | Set-MailboxDatabase  -MailboxRetention 45.00:00:00

Open in new window

For server wise

get-mailboxdatabase -server <ServerName> | Set-MailboxDatabase  -MailboxRetention 45.00:00:00

Open in new window

Amit KumarCommented:
There will not be any major service impact, you just need to take care of storage capacity, in case if you are planning to retain deleted mailboxes for 365 days or more than 30 days.
Jerry SeinfieldAuthor Commented:
so the correct cmdlet will be?

get-mailboxdatabase | Set-MailboxDatabase  -MailboxRetention 365.00:00:00

Should I restart any Exchange service on the Mailbox server?
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

Amit KumarCommented:
No need to bounce any service.
Jerry SeinfieldAuthor Commented:
can you please this command works for Exchange 2013? and has the 365 day of the year?

get-mailboxdatabase | Set-MailboxDatabase  -MailboxRetention 365.00:00:00
Amit KumarCommented:
Please run Get-MailboxDatabase powershell and see if you can see all DBs.

and try below one for single database once:

Set-MailboxDatabase  "DBName" -MailboxRetention 365.00:00:00

If yes then this command should work.

Please paste if any error you can see.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Amit KumarCommented:
You can do one more thing apply it with CSV file.

I have attached a CSV file in which you can provide DBName,

1. don't delete First line named "Identity"
2. Replace DB01 and DB02 with your Prod DB names as you have 50 DBs so you can hit a enter then put DB name e.g.


Keep this CSV file in a folder and change your working directory in Powershell.

Now below command will import CSV with DB names and change retention period:

Import-Csv .\DBname.csv | foreach {set-mailboxdatabase $_.Identity -MailboxRetention 365.00:00:00}

Open in new window

Jerry SeinfieldAuthor Commented:
Hi Amit, the command above worked, however only changed the deleted mailboxes and set to 365, the deleted items still shows 14 days

Any ideas on why?
Amit KumarCommented:
Deleted Item retention is diff. attribute, sorry I forgot to tell you to change procedure for that. Please find below mentioned.

You just need to replace -MailboxRetention with -DeletedItemRetention

Set-MailboxDatabase  -DeletedItemRetention 365.00:00:00.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.