Delete Exchange Users Old Mail

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 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.

I attempted to run the following script:
Search-Mailbox -Identity SOMEUSERNAME -SearchQuery '(Received:01/01/2012..12/31/2012)' -Deletecontent -Force

And I was told that the “search-mailbox” command was not found. Great. Verified that I was using the Exchange Management Powershell instead of just Windows PS. True story.

After a lot of searching I realized that our former Exchange Admin wasn’t very good at PowerShell. The Admin Tasks Management Powershell add-in was not available.

Check Available PowerShell Snap-ins
Get-PSSnapin
Notice Exchange Server Admin Tasks is not available.

Verify that the plugin is available
Get-PSSnapin -registered

Add the snap-in
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010

I ended up closing the powershell window and then re-opening it. My search mailbox and delete content commands now work!

Other commands I did:
Added my user to the Discovery Management role in the ECP (https://yourmailserver.tld/ecp)
Created two new groups to allow the import and export of mailboxes, and then the exchange support and diagnostics:
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."
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."

Windows 8 Startup Folder

Windows 8, well now 8.1, has a lot of changes to it. Took me a while to get used to it – on dual monitors or with a touch screen it’s pretty decent.

Anyway, I couldn’t find my startup folder easily. Windows 7/Vista you could hit start, then type in “startup” and away you go. Before that you could explore all users by right-clicking on start and then drill down to find your startup folder.

BTW, I know that the startup folder resides in the c:\users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\ directory, but who wants to type out all that?

Win + R, “shell:startup”, enter