question

Sanjay-4478 avatar image
0 Votes"
Sanjay-4478 asked KaelYao-MSFT edited

I want to delete 90 days older disconnected mailbox from Exchange 2013 server.

Want to delete 90 days older disabled mailbox from exchange 2013 environment. I know cmd to remove all the disabled mailboxes. but can you advise if any script available to delete 90 days older mailbox not all

office-exchange-server-administration
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

KaelYao-MSFT avatar image
0 Votes"
KaelYao-MSFT answered KaelYao-MSFT edited

Hi @Sanjay-4478

By default, the retention period of disabled mailboxes on each database in Exchange 2013 is 30 days.
It means disabled mailboxes which are older than 30 days will be removed automatically.
88476-35.png


If you have changed the default setting and would like to manually delete the disabled mailboxes which are 90 days older.
You may use this command to first list all these disable mailboxes:

 Get-MailboxDatabase | foreach {Get-MailboxStatistics -Database $_.DistinguishedName} | where {$_.DisconnectReason -eq "Disabled"} | where {$_.DisconnectDate -le (get-date).adddays(-90)} | fl DisplayName,Database,DisconnectDate

And run this command to remove the disabled mailboxes:

 Get-MailboxDatabase | foreach {Get-MailboxStatistics -Database $_.DistinguishedName} | where {$_.DisconnectReason -eq "Disabled"} | where {$_.DisconnectDate -le (get-date).adddays(-90)} | ForEach {Remove-StoreMailbox –Database $_.database –identity $_.mailboxguid –MailboxState Disabled}

If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


35.png (34.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.