Sunday, November 01, 2015

Automated compacting and copying of Microsoft Outlook PST files

Here's a way to automatically compact and backup all of your Microsoft Outlook PST data files on your Windows PC using only free software, AutoIT and PowerShell. AutoIT is freeware, and PowerShell is included in Microsoft Windows. Compacting your PST files before you back them up can reduce the amount of disk space required both at the source and destination locations of your backup.

So, to get started:

  1. Get the free AutoIT Full Installation and AutoIT Script Editor from the AutoIT Downloads page.
  2. Ensure PowerShell scripts that you create can run on your computer.
  3. Create an AutoIT script that, when the Mail control panel is open, will compact all PST files and then close the Mail control panel.
  4. Create a Powershell script that opens the Mail control panel and then executes the AutoIT script.

Here below are the AutoIT and Powershell scripts that I am running on my Windows 8.1 PC with Outlook 2013. I have a Windows Shortcut to my PowerShell script so that every time I log into my PC, my Outlook PST data files are compacted and backed up before Outlook is opened. I use the PowerShell script to also open other applications so that I may work on them while the Outlook PST data files are being backed up. Please feel free to copy the scripts below and modify them to work for you.

I am using Synology's Cloud Station to keep most of the data files on my laptop in sync with a Synology NAS, but Cloud Station doesn't work well with Outlook PST data files, which is why Cloud Station is configured by default to exclude the synchronization of files with a PST extension.

AutoIT script


PowerShell script



2 comments:

Nancy Vogan said...

Thank you for your post and for the script! I will use it maybe some day. I was looking for this solution because I moved my mail from one computer to another. Outside the express 6 on both machines. I imported the address book, incoming messages were pulled from the server (stored there). Than I found visit website to learn more horde open transfer and figured out how to do it corectly. From the created file, you can get data using any version of Outlook, using the import or creating an item. All is simply the best!

Anonymous said...

We use G Suite, the Control Panel Item Mail label is different:
Mail Setup - email@domain.com - G Suite

It worked like a charm for us after editing these lines:

15: WinWait("Mail Setup", "Data Files")
16: ControlClick("Mail Setup", "Data Files", "Button2")
48: WinClose("Mail Setup")

Thank you