Automated-Office-Updates

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_

-Mike

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.

Configuration

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

-Office

The folder containing the Office Deployment Tool (ODT).

-Config

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

-Days

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.

-L

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

-Subject

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

-SendTo

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

-From

The from address the log should be sent from.

-Smtp

The DNS name or IP address of the SMTP server.

-User

The user account to connect to the SMTP server.

-Pwd

The password for the user account.

-UseSsl

Connect to the SMTP server using SSL.

Example

Office-Update.ps1 -Office C:\officesrc -Config config.xml -Days 60 -L C:\scripts\logs -Subject 'Server: Office Update' -SendTo me@contoso.com -From Office-Update@contoso.com -Smtp exch01.contoso.com -User me@contoso.com -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.