{"id":1196,"date":"2014-05-21T10:33:55","date_gmt":"2014-05-21T15:33:55","guid":{"rendered":"http:\/\/it.thelibrarie.com\/weblog\/?p=1196"},"modified":"2014-05-21T10:33:55","modified_gmt":"2014-05-21T15:33:55","slug":"delete-exchange-users-old-mail","status":"publish","type":"post","link":"https:\/\/it.thelibrarie.com\/weblog\/2014\/05\/delete-exchange-users-old-mail\/","title":{"rendered":"Delete Exchange Users Old Mail"},"content":{"rendered":"<p>I was tasked with deleting a service account users old mail.  Our CRM Mailbox user had 29.5GB of old mail floating around that needed to be purged.  Adding access to the account was a no-no (and would probably crash out Outlook for a while) due to company policies.  Powershell to the rescue?<\/p>\n<p>I should probably mention that this is on Exchange 2010 in a DAG (2 servers) with SP3 hotfix 4 applied.  Yes, I also know hotfix 5 is available.<\/p>\n<p><strong>I attempted to run the following script:<\/strong><br \/>\n<code>Search-Mailbox -Identity SOMEUSERNAME -SearchQuery '(Received:01\/01\/2012..12\/31\/2012)' -Deletecontent -Force<\/code><\/p>\n<p>And I was told that the &#8220;search-mailbox&#8221; command was not found.  Great.  Verified that I was using the Exchange Management Powershell instead of just Windows PS.  True story.<\/p>\n<p>After a lot of searching I realized that our former Exchange Admin wasn&#8217;t very good at PowerShell.  The Admin Tasks Management Powershell add-in was not available.<\/p>\n<p><strong>Check Available PowerShell Snap-ins<\/strong><br \/>\n<code>Get-PSSnapin<\/code><br \/>\nNotice Exchange Server Admin Tasks is not available.<\/p>\n<p><strong>Verify that the plugin is available<\/strong><br \/>\n<code>Get-PSSnapin -registered<\/code><\/p>\n<p><strong>Add the snap-in<\/strong><br \/>\n<code>Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010<\/code><\/p>\n<p>I ended up closing the powershell window and then re-opening it.  My search mailbox and delete content commands now work!<\/p>\n<p><strong>Other commands I did:<\/strong><br \/>\nAdded my user to the Discovery Management role in the ECP (https:\/\/yourmailserver.tld\/ecp)<br \/>\nCreated two new groups to allow the import and export of mailboxes, and then the exchange support and diagnostics:<br \/>\n<code>New-RoleGroup -Name \"Exchange Mailbox Import Export\" -Roles \"Mailbox Import Export\" -Members \"domain\\username\" -DisplayName \"Exchange Mailbox Import Export\" -Description \"This group handles permissions to the import and export commands in powershell.\"<\/code><br \/>\n<code>New-RoleGroup -Name \"Exchange Support and Diagnostics\" -Roles \"Support Diagnostics\" -Members \"domain\\username\" -DisplayName \"Exchange Support Diagnostics\" -Description \"This group handles permissions to the support diagnostics cmdlets in exchange.\"<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was tasked with deleting a service account users old mail. Our CRM Mailbox user had 29.5GB of old mail floating around that needed to be purged. Adding access to the account was a no-no (and would probably crash out Outlook for a while) due to company policies. Powershell to the rescue? I should probably &hellip; <a href=\"https:\/\/it.thelibrarie.com\/weblog\/2014\/05\/delete-exchange-users-old-mail\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Delete Exchange Users Old Mail<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-1196","post","type-post","status-publish","format-standard","hentry","category-microsoft"],"_links":{"self":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts\/1196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/comments?post=1196"}],"version-history":[{"count":1,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts\/1196\/revisions"}],"predecessor-version":[{"id":1197,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts\/1196\/revisions\/1197"}],"wp:attachment":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/media?parent=1196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/categories?post=1196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/tags?post=1196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}