One of my clients refuses to buy a proper email archiving solution so to accomplish generally the same goals (with more manual interaction), I wrote this basic script in PowerShell which exports the entire Journal to a PST and then removes it from the journal to recover the space within Exchange’s database.
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin $endDateFormatted = Get-Date -format d $fileName = Get-Date -format MMMd-yyyy $pstFile = "E:\Export\Journal-" + $fileName + ".pst" Export-Mailbox -identity journal -IncludeFolders "\Inbox" -StartDate 01/01/2000 -EndDate $endDateFormatted -Confirm:$false -PSTFolderPath $pstFile -DeleteContent -Baditemlimit 1000 NET USE * /delete /y NET USE P: "\\SERVERNAME.DOMAIN.TLD\SHARENAME" password /user:DOMAIN\username $destination = "P:\Journal-" + $fileName + ".pst" Move-Item $pstFile $destination NET USE P: /delete /y
The following assumptions are made:
- The Exchange Administration Tools are installed on the machine that this script is running on
- You will be using the E: drive as a temporary storage location for the PST until the export complete
- You have a specific share on the network that you will be copying the PST to when the export is complete
- The drive letter P: is not automatically mapped when this user logs in