{"id":396,"date":"2019-04-24T17:36:23","date_gmt":"2019-04-24T22:36:23","guid":{"rendered":"http:\/\/itblog.ldlnet.net\/?p=396"},"modified":"2019-04-24T17:36:23","modified_gmt":"2019-04-24T22:36:23","slug":"purging-soft-deleted-mailboxes-from-exchange-server","status":"publish","type":"post","link":"https:\/\/itblog.ldlnet.net\/index.php\/2019\/04\/24\/purging-soft-deleted-mailboxes-from-exchange-server\/","title":{"rendered":"Purging Soft Deleted mailboxes from Exchange Server"},"content":{"rendered":"\n<p>If you&#8217;re a seasoned administrator, you have knowledge that in Exchange, the database settings will allow you to set the deleted mailbox retention. The default is 30 days, but sometimes you need to purge all those deleted mailboxes to do some &#8216;spring cleaning&#8217; as it were. Note that doing these cmdlets does not change the &#8216;Whitespace&#8217; of the database or the size. In my case, I had to purge everything of a toxic individual that was tainting my network much to my disappointment and did the following to complete that task.<\/p>\n\n\n\n<p>The following cmdlet will seek all Soft Deleted mailboxes within the database you select and manually purge them from Exchange.<\/p>\n\n\n<pre class=\"lang:Powershell nums:False\" title=\"Remove all Soft Deleted Mailboxes from a database in Exchange\">Get-MailboxStatistics -Database \"DB01\" | where {$_.DisconnectReason -eq \"SoftDeleted\"} | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted}<\/pre>\n\n\n\n<p>Now, should you only want to remove one mailbox, you will need to get the GUID of that Soft Deleted mailbox first so that you can enter it for the identity parameter.<\/p>\n\n\n<pre class=\"lang:Powershell nums:False\" title=\"Remove a Soft Deleted Mailbox from Exchange\">Get-MailboxStatistics -Database \"DB01\" | where {$_.DisconnectReason -eq \"SoftDeleted\"} | Sort-Object DisconnectDate -descending | ft -a -wr\n\nGet the Mailbox GUID in the list for the deleted mailbox. \nThen Run:\n\nRemove-StoreMailbox -Database \"DB01\" -Identity \"mailboxguid\" -MailboxState SoftDeleted | ft -a -wr<\/pre>\n\n\n\n<p>You can also preform a similar task for a disabled mailbox:<\/p>\n\n\n<pre class=\"lang:Powershell nums:False\" title=\"Remove a Disabled Mailbox from Exchange\">Get-MailboxStatistics -Database \"DB01\" | where {$_.DisconnectReason -eq \"Disabled\"} | Sort-Object DisconnectDate -descending | ft -a -wr\n\nGet the Mailbox GUID in the list for the deleted mailbox. \nThen Run:\n\nRemove-StoreMailbox -Database \"DB01\" -Identity \"mailboxguid\" -MailboxState Disabled | ft -a -wr<\/pre>\n\n\n\n<p>You can perform the task on all disabled mailboxes for that database as well:<\/p>\n\n\n<pre class=\"lang:Powershell nums:False\" title=\"Remove all Disabled Mailboxes from a database in Exchange\">Get-MailboxStatistics -Database \"DB01\" | where {$_.DisconnectReason -eq \"Disabled\"} | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState Disabled}<\/pre>\n\n\n\n<p class=\"has-text-color has-small-font-size has-medium-pink-color\"><em><strong>NOTE: I would be very careful when performing either of these cmdlets as they will completely purge the mailboxes from the schema. If these cmdlets assist you with your &#8216;spring cleaning&#8217;, I will have been happy to assist.<\/strong><\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"text-align:center\">HAPPY PURGING!<br>PLEASE COMMENT!<br>IGNORANCE IS NOT BLISS!<\/h2>\n\n\n\n<p class=\"has-small-font-size\"><strong>References:<\/strong><br><em><strong><a rel=\"noreferrer noopener\" aria-label=\"Purging Deleted Mailboxes on Exchange 2013 (opens in a new tab)\" href=\"https:\/\/community.spiceworks.com\/topic\/1953682-purging-deleted-mailboxes-on-exchange-2013\" target=\"_blank\">Purging Deleted Mailboxes on Exchange 2013<\/a><\/strong><\/em><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/www.servermonkey.com\/?utm_source=ldlnet.net&amp;utm_medium=referral\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" width=\"468\" height=\"61\" src=\"https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2019\/04\/banner-100.jpg\" alt=\"Server Monkey\" class=\"wp-image-397\" srcset=\"https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2019\/04\/banner-100.jpg 468w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2019\/04\/banner-100-300x39.jpg 300w\" sizes=\"auto, (max-width: 468px) 100vw, 468px\" \/><\/a><figcaption>LDLNET LLC&#8217;s Preferred Server Equipment Hardware Vendor<\/figcaption><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re a seasoned administrator, you have knowledge that in Exchange, the database settings will allow you to set the deleted mailbox<\/p>\n<p class=\"link-more\"><a class=\"myButt \" href=\"https:\/\/itblog.ldlnet.net\/index.php\/2019\/04\/24\/purging-soft-deleted-mailboxes-from-exchange-server\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":161,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,2,3],"tags":[105,15,9,150,149,151,110,8,13],"class_list":["post-396","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-exchange","category-general","category-powershell","tag-cmd","tag-cmdlet","tag-exchange","tag-exchange-2013","tag-exchange-2016","tag-exchange-2019","tag-mailbox","tag-powershell","tag-script","odd"],"_links":{"self":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/396","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/comments?post=396"}],"version-history":[{"count":1,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/396\/revisions"}],"predecessor-version":[{"id":398,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/396\/revisions\/398"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media\/161"}],"wp:attachment":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media?parent=396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/categories?post=396"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/tags?post=396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}