Exchange Management Shell (EMS)

Share on:

Exchange Management Shell is the core of Microsoft Exchange. The GUI was an after thought, especially in Exchange 2007. Here are some useful commands that I use often.

Export Company to PSTs

Get-Mailbox -OrganizationalUnit SBSUsers | Export-Mailbox -PSTFolderPath C:pathtosave -BadItemLimit 10000 -ExcludeFolders “Junk E-Mail”,”Deleted Items” -StartDate “01/01/2009 00:01:00”

This is useful for moving an entire exchange store into PST format. This can be used for Exchange to External mail system migrations, or just to have a backup to access mailboxes at that point in time.

Clear Calendar by Exporting to PSTs

export-Mailbox -Identity domainuser -BadItemLimit 100 -DeleteContent -IncludeFolders “Calendar” -PSTFolderPath C:Usersctituspsts

I’ve used this on firms that store calendar entries in another program and sync to outlook. Sometimes these syncs can duplicate entries causing a huge mess in outlook. This will clear the entire outlook calender into a PST file and give you a clean slate to work off of.

Export Single Mailbox

Export-Mailbox -Identity domainuser -PSTFolderPath C:pathtosavepsts -BadItemLimit 100 -ExcludeFolders “Junk E-Mail”,”Deleted Items”

Typically, this is the most used command in EMS. This exports one mailbox to PST. Great for when someone leaves your company and you are ready to delete their account. I always back their mailbox up to PST and then purge the user.

Generate Mailbox Size Report to Text File

Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label=”TotalItemSize(MB)”;expression={$_.TotalItemSize.Value.ToMB()}},ItemCount >c:mailboxsize.txt

Here is a clean way to examine your mailbox sizes. It exports Display Name, Mailbox Size in MB, and Item Count and sorts them by descending mailbox size to the text file. Very useful when dealing with Exchange 2007.

There are many other great EMS scripts and commands, but these are the ones I use on a regular basis. If you have one that you’d like to contribute, please leave it a comment.