Worklet: Install Microsoft Office on Windows

  • 4 March 2021
  • 2 replies

Userlevel 4

Hi all, I thought I’d upload the worklet I am using to install Microsoft Office (I know, there’s probably other and better ways to do this but this method works for us.)

I downloaded the Office Deployment Tool via, extracted it and uploaded the setup executable to my Worklet and configured the XML to fit my needs - you can also configure that here - and uploaded it to my Worklet. You may need to rename them in the worklet so they have your correct the filenames.

The evaluation first checks whether the Microsoft Office directory exists in Program Files, if found, it then uses the O365 installer. The remediation then logs everything in verbose to a msoffice.log file, copies the uploaded files to a temp directory, checks whether the path exists, if so, writes the output and skips the install, otherwise it installs it.


if (Test-Path -Path "C:\Program Files\Microsoft Office") 
exit 0
Exit 1


Start-Transcript -Verbose -Path "c:\temp\msoffice.log"

Copy-Item configurationx64.xml -Destination "c:\temp\configurationx64.xml" -Verbose
Copy-Item msoffice.exe -Destination "c:\temp\msoffice.exe" -Verbose

$path = "C:\Program Files\Microsoft Office"

# Check if Microsoft Office 365 is installed
if (Test-Path $path -Verbose) {
Write-Output "Microsoft Office 365 is already installed. Skipping..."
Write-Output "Exit Code: $LASTEXITCODE"
else {
Write-Output "Microsoft Office 365 not installed, installing..."
Start-Process -FilePath "c:\temp\msoffice.exe" -argumentlist '/configure c:\temp\configurationx64.xml' -Verbose
Write-Output "Microsoft Office 365 has been installed."


Hope this helps someone.

2 replies

thank you for this, worked like a charm.


Thanks!!  This really helped me get started with my Office365 deployment.  Microsoft is clown-shoes… even after 25 years, they still can’t make a straight forward upgrade process for Office.

I wanted to share my additions/tweaks to this script:

The evaluation above only really checks to see that Office is present.  This reg query will detect the presence of Office365/M365 and then fire off the remediation code if its not present.

I set my XML config to shut down the running Office applications prior to performing the installations.


$uninstallKeys = Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

$O365 = "Microsoft 365*"
$O365Check = $uninstallKeys | Where-Object { $_.GetValue("DisplayName") -like $O365 }

if ($O365Check)
Exit 0
Exit 1

Its too bad that Start-Process tells you precisely nothing about what is going on with the endpoint.  I bet there is a way to execute this and have it give you some meaningful output to log, but I didn’t have time to dig into it further.



New-Item -Path 'C:\Temp' -ItemType Directory -Force -ErrorAction SilentlyContinue

Start-Transcript -Verbose -Path "C:\Temp\M365\msoffice.log"

Write-Output "Copying install files..."

Copy-Item configuration.xml -Destination "C:\Temp\M365\configuration.xml" -Verbose

Copy-Item setup.exe -Destination "C:\Temp\M365\setup.exe" -Verbose

Write-Output "Install files copied to C:\Temp."

Write-Output "Executing install command..."

Start-Process -FilePath "C:\Temp\M365\Setup.exe" -argumentlist '/configure C:\Temp\M365\configuration.xml' -Verbose -Wait

Write-Output "Microsoft Office 365 install command executed. Please be patient while it installs! DO NOT interrupt this installation!"