How to keep deleted emails for longer in Outlook via Exchange Online

You can have your Outlook emails permanently deleted and moved to the Recoverable Items > Deletions folder, where they will be kept for up to 14 days. If you need them to be kept for longer, you can increase the number of days to up to 30.

If you are a home user, then this article is not for you, but you can continue to read along in order to learn something new.

Before continuing, we must note that you can only make the necessary changes using Exchange Online PowerShell. This is strange, but it is what it is currently, so until Microsoft makes some changes, we have to work with what we have.

Keep permanently deleted emails longer in Outlook

For whatever reason, you might want to keep deleted emails for a little bit longer. This guide will aid in achieving that task. We will cover the following:

Related Article: How to create, add, delete, and use Outlook Email Alias or Microsoft Accounts

  • Select the correct permissions
  • Connect Windows PowerShell to Exchange Online
  • Disconnect the remote PowerShell session

Select the correct permissions

Permissions must be assigned that makes sense for this specific issue. To do this, visit and check the section, Recipient provisioning permissions.

Connect Windows PowerShell to Exchange Online

In order to make things work, we must connect your Exchange Online server with Windows PowerShell. We can do this by launching PowerShell from your local computer and then copy and paste the following command:

$User Credential = Get-Credential

When the login dialog box appears, please type in your school or work account followed by your password, and click OK. The next step is to copy and paste the following command:

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $UserCredential -Authentication Basic -AllowRedirection

Also, run this command after performing the previous:

Import-PSSession $Session -DisableNameChecking

Disconnect the remote PowerShell session

After all, that’s done, we suggest not closing Windows PowerShell outright, but instead disconnecting it. If you close the window, you could use up all the remote PowerShell sessions available to you, and you’ll need to wait for the sessions to expire.

To end your session, copy and paste the following command, then press Enter.

Remove-PS Session $Session

Change how long permanently deleted items are kept

Now it’s time to do what you originally came here to do, so please open Windows PowerShell again and type in the following command, then hit Enter.

Set-Mailbox -Identity “Emily Maier” -Retain Deleted Items For 30

This command will set the deletion date for all messages in the mailbox of Emily Maier to 30 days from now.

As for making changes to all mailboxes, please copy and paste the following:

Get-Mailbox -ResultSize unlimited -Filter {(RecipientTypeDetails -eq ‘UserMailbox’)} | Set-Mailbox -RetainDeletedItemsFor 30

OK, so that’s it and we’re done. For more info visit

Leave a Comment