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

Sanjay 21 Reputation points
2021-04-15T18:18:35.337+00:00

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

Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,795 questions
0 comments No comments
{count} votes

Accepted answer
  1. Kael Yao-MSFT 37,696 Reputation points Microsoft Vendor
    2021-04-16T03:04:26.557+00:00

    Hi @Sanjay

    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.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.