I created a PowerShell 4 script to backup the Outlook 2013 VbaProject.OTM file by copying it from the production directory to a backup directory, and adding a filename suffix of the current date and time. The copied version has the modified date and time of when the VbaProject.OTM was first saved. I've spent all morning researching posts trying to figure out how to change the Date Modified property of the backup file to the current date and time, but everything I've tried just ends in error messages. Is there a simple was to accomplish this?
# FD_VBA_Backup.ps1 $date = get-date -format "MMddyyyy HHmm" $fnft = "VbaProject - " + $date + ".OTM" $source = "C:\Users\OCCReportManager\AppData\Roaming\Microsoft\Outlook\VbaProject.OTM" $dest = "D:\FD Automation VBA Backups\" + $fnft copy-item $source $dest # results in eg. "VbaProject - 07202015 0936.OTM"
There was a similar question about how to create an empty file and set the date property. The solution to my question was also there in a single line, but not easy to find. The title of the other question makes it not obvious that the solution can be found within, as I need to change the date on an existing file, not create a new file. Ref: Equivalent of Linux `touch` to create an empty file with PowerShell? .