I was having a conversation at lunch with a friend who needed to recover some items for a user from the Exchange Dumpster. So I came up with a one-liner to help you do just that but BEFORE i can really give you the one-liner I need to give you some background.
First there is a Deleted Items folder in your Exchange Mailbox. When you delete an email it goes here first (for many people that is as far as it goes but that’s another blog post…).
A user can simply look here in the their deleted Items folder and find something they have deleted if that folder has not yet been emptied.
If the Deleted Items folder has been emptied it will remain in the Deletions folder (Dumpster) for the next 14 days by default. During this time the user can use Outlook and or OWA to Recover Items that are now in the Dumpster. I love this feature but it’s not very much fun for the user if they have deleted a lot of items lately.
So to make things a little easier on the user you can recover all the items in PowerShell and then export them so the user can sort them to their hearts content. The tricky part here is that you can’t drop them directly back into the mailbox you’re searching. You can use the DiscoverySearchMailbox but I keep an admin mailbox around that I use for just such occasions. I call this mailbox SearchAdmin and it will become the Target mailbox.
The PowerShell command looks like this:
Search-Mailbox -identity ebuford -SearchDumpsterOnly -TargetMailbox SearchAdmin –TargetFolder ebufordDumpster
The three items in red are user mailbox you’re searching (ebuford) the target mailbox your dropping the files in (SearchAdmin) and the name of the Folder you want to dump them in (ebufordDumpster).
Once you’ve got them in the new folder you can export to a PST and then Import them back into the users mailbox. Now this isn’t the most straightforward admin task you’re going to do, but if you really want to please a user (or maybe your boss) this will make you some brownie points!
For many reasons we sometimes need to Import or Export all or part of a mailbox to or from a PST. Before you can Import or Export you’ll need to have permission to actually SEE the commandlets in Exchange.
So start by getting the proper permissions you can give them to a user, in this case to ebuford:
If you’d rather give permissions to a security group like Administrators you can do that too:
Once you’ve given rights you’re going to need to log out and then log back in to see the commandlets.
If you’d like to know who has the role assigned to them:
Ok so now we have the role let’s get busy!
Let’s say you need to export a full mailbox to a PST here’s how we’ll tackle that. We will need to create an new export request using the New-MailboxExportRequest commandlet.
Specify the username for the mailbox and then give a full UNC path for the PST file you’re exporting. You can’t use C:\PSTs\ebuford.pst it must be a full UNC path. So if you’re trying to get to the PSTs folder on the C:\ drive of your exchange server named Exchange2013 then try this: \\Exchange2013\C$\PSTs\ebuford.pst
-Mailbox username -FilePath \\files\pstarchive
ok so you started the mailbox export and you want to see how it’s doing. You can get the stats for a single mailbox export like this:
But what if you have a few exports running at the same time? Try this:
Ok what about Importing a PST?
Well it’s basically everything we just learned but we’re going to use the NewImportRequest Commandlet.
You can also use the Get-MailboxImportRequest and Get-MailboxImportRequestStatistics.
So far so good – now let’s talk a bit about some of the options for these commands.
Let’s say I’m exporting a pst but I don’t want objects from the deleted items folder. I can use the –ExcludeFolders parameter like this:
New-MailboxExportRequest -Mailbox ebuford – ExcludeFolders #DeletedItems# –FilePath “\\FileServer\PSTs\ebuford.pst”
Make sure you place ## around the folder
Another option might be to only get the Inbox from a mailbox you can do this just as easily using the –IncludeFolders parameter like this:
New-MailboxExportRequest -Mailbox ebuford – IncludeFolders #Inbox# –FilePath “\\FileServer\PSTs\ebuford.pst”
Here is a list of well- know folders:
Frequently I start mailbox migrations on a Friday night and then babysit the moves all weekend long (or longer). Clients like to know some basic info about the move just to check to make certain things are going as expected.
Now when you’re moving hundreds of users at a time the last thing you want to do is try to count all the users that are completed so you can give an update to your clients. So I created a simple powershell script to tell me how many users are Queued, completed, failed or moving. Hope this is helpful: