Convert Office Outlook VBA Macro To PowerShell

Exchange, Office 365

In my profession I have always been presented with problems or requests that provide a bit of a challenge. One such challenge was automating local PST archiving (not to be confused with online archiving). There is a MAPI property on each folder in the mailbox that will identify whether the folder is to be locally archived or not. This property resides within the mailbox itself and there is no automated way of setting this across the mailbox without user intervention. Outlook provides a button that sets all folders to locally archive but new folders created will not inherit the setting.

The only documentation I could find was located on MSDN here in VBA format. My final solution was to create an Outlook add-in to avoid having to use Group Policy to allow outside access to the application. If you are looking for this solution you can download the add-in here. Through the process I was able to take the VBA macro and convert it into VBS, C# and PowerShell. Here is the before and after when converting VBA to PowerShell that can be applied across any VBA macros that you might find.

VBA Code Before:

PowerShell Code After:

Print Friendly, PDF & Email

Leave a Reply