PowerShell script to automate the downloading and maintenance of click-to-run Office 365/2019 update files.

For full instructions and documentation, visit my blog post

Please consider donating to support my work:

Automated Office Updates can also be downloaded from:

Tweet me if you have questions: @mikegalvin_


Features and Requirements

Generating A Password File

The password used for SMTP server authentication must be in an encrypted text file. To generate the password file, run the following command in PowerShell, on the computer that is going to run the script and logged in with the user that will be running the script. When you run the command you will be prompted for a username and password. Enter the username and password you want to use to authenticate to your SMTP server.

Please note: This is only required if you need to authenticate to the SMTP server when send the log via e-mail.

$creds = Get-Credential
$creds.Password | ConvertFrom-SecureString | Set-Content c:\scripts\ps-script-pwd.txt

After running the commands, you will have a text file containing the encrypted password. When configuring the -Pwd switch enter the path and file name of this file.


Here’s a list of all the command line switches and example configurations.


The folder containing the Office Deployment Tool (ODT).


The name of the configuration xml file for the Office ODT. It must be located in the same folder as the ODT.


The number of days that you wish to keep old update files for. If you do not configure this option, no old files will be removed.


The path to output the log file to. The file name will be Office-Update.log.


The email subject that the email should have. Encapulate with single or double quotes.


The e-mail address the log should be sent to.


The from address the log should be sent from.


The DNS name or IP address of the SMTP server.


The user account to connect to the SMTP server.


The password for the user account.


Connect to the SMTP server using SSL.


Office-Update.ps1 -Office C:\officesrc -Config config.xml -Days 60 -L C:\scripts\logs -Subject 'Server: Office Update' -SendTo -From -Smtp -User -Pwd P@ssw0rd -UseSsl

The above command will run the script, download the Office files to C:\officesrc\Office. It will use a configuration file called config.xml in the C:\officesrc folder. Any update files older than 60 days will be removed. If the download is successful a log file is generated and it can be e-mailed with a custom subject line as a notification that a download occurred.