This quick, easy to follow guide will help you to export a CSV file listing all of the mail items within their respective folders and sub-folders through the dark magic of PowerShell. This script will work on both Exchange and O365.

Set-ExecutionPolicy RemoteSigned
Set-ExecutionPolicy Unrestricted
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $o365cred -Authentication Basic -AllowRedirection
Import-PSSession $session

Pretty darn easy, right? Now you just need to run one more script to export the mail items to a file.

Note: before running this script, be sure to change "[email protected]" to the UPN of the mailbox you actually want to export a mail items list for - unless it really is [email protected] - in that case feel free to carry on.

get-mailboxfolderstatistics -identity [email protected] | select FolderPath, FolderSize, ItemsinFolder, ItemsInFolderandSubfolders | Export-csv example.csv

That’s it, you’re done!

Share this post