Tips and Resources

Automated Office 2021 Deploy with Group Policy and PowerShell

Guide for deploying Microsoft Office 2021 on your network using Group policy & PowerShell

Prepare Office 2021 Files

Download the Office Deployment Tool officedeploymenttool_15028-20242.exe from Microsoft here: https://www.microsoft.com/en-us/download/details.aspx?id=49117

Once downloaded, run the downloaded file. When prompted for an installation folder, make a new folder on your machine, say on the desktop, called MicrosoftOffice2021ProPlus and choose this new folder as the installation location.

Open the folder MicrosoftOffice2021ProPlus and edit the file configuration-Office2021Enterprise.xml with a text editor like notepad. Change the Configuration section to reflect the office products you wish to deploy. Our site doesn't use any other Office products than what is included with Professional Plus so our .xml file looks like this:

<!-- Office 2021 enterprise client configuration file sample. To be used for Office 2021 enterprise volume licensed products only, including Office 2021 Professional Plus, Visio 2021, and Project 2021.
Do not use this sample to install Office 365 products.
For detailed information regarding configuration options visit: http://aka.ms/ODT. To use the configuration file be sure to remove the comments
The following sample allows you to download and install Office 2021 Professional Plus, Visio 2021 Professional, and Project 2021 Professional directly from the Office CDN.
This configuration file will remove all other Click-to-Run products in order to avoid product conflicts and ensure successful setup.
-->
<Configuration ID="699f644d-9780-40d5-b379-b62c74a8dffb">
<Add OfficeClientEdition="64" Channel="PerpetualVL2021">
<Product ID="ProPlus2021Volume" PIDKEY="FXYTK-NJJ8C-GB6DW-3DYQT-6F7TH">
<Language ID="en-us" />
<ExcludeApp ID="Lync" />
</Product>
</Add>
<Property Name="AUTOACTIVATE" Value="1" />
<Updates Enabled="TRUE" />
<RemoveMSI />
<Display Level="None" AcceptEULA="TRUE" />
</Configuration>

You can also create your own config.xml file from the Microsoft Office Customization Tool https://config.office.com/deploymentsettings

Save the file once you've got it configured with the correct products. Open up a PowerShell prompt and browse to the MicrosoftOffice2021ProPlus folder.

Run the following to download the Office 2021 installer for the products configured in the xml file:

 .\setup.exe /download .\configuration-Office2021Enterprise.xml

After a few moments, the download will be complete. Copy the MicrosoftOffice2021ProPlus folder over to your software deployment server share.

PowerShell script for Office 2021 deployment

Office 2021 can't be installed on computers with Office 2016 or 2019 installed, so these must be uninstalled prior to installing Office 2021. Office 2016 can be automatically removed using the <RemoveMSI /> property in the configuration-Office2021Enterprise.xml file, but this won't remove Office 2019.

Microsoft don't provide an MSI to install office; one alternative method of removing previous office installs and then installing Office 2021 is by using a PowerShell script set to run on system start up. This example script checks to see if Office 2021 is already installed, if it is it immediately exits the script. Otherwise it removes Office 2019 if it's installed and installs Office 2021.

#Check for Office 2021 installation
$officeInstall = Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration' 'ProductReleaseIds'

if($officeInstall -eq "ProPlus2021Volume"){
Exit
}

if($officeInstall -eq "ProPlus2019Volume"){
#Uninstall 2019
$now = Get-Date -format "dd-MMM-yyy HH:mm:ss"
Write-Output $now "Office 2019 found, uninstalling" >> c:\Office2021.log

\\server\deploymentShare\MicrosoftOffice2021ProPlus\setup.exe /configure \\server\deploymentShare\MicrosoftOffice2021ProPlus\configuration-RemoveOffice2019.xml
}

#install office 2021
$now = Get-Date -format "dd-MMM-yyy HH:mm:ss"
Write-Output $now "Installing Office 2021" >> c:\Office2021.log
\\server\deploymentShare\MicrosoftOffice2021ProPlus\setup.exe /configure \\server\deploymentShare\MicrosoftOffice2021ProPlus\configuration-Office2021Enterprise.xml

configuration-RemoveOffice2019.xml looks like this:

<Configuration>
<Property Name="FORCEAPPSHUTDOWN" Value="TRUE" />

<Remove All="TRUE">
<Product ID="ProPlus2019Volume">
</Product>
</Remove>

<RemoveMSI All="True" />

</Configuration>

Add this script to a group policy object targeting your computers in the start up scripts section Computer Configuration -> Policies -> Windows Settings -> Scripts -> Startup -> PowerShell Scripts

References

https://www.delftstack.com/howto/powershell/powershell-get-registry-value/

https://stackoverflow.com/questions/52892882/how-to-detect-office-2019-programmatically

https://docs.microsoft.com/en-us/deployoffice/overview-office-deployment-tool

https://www.prajwaldesai.com/deploy-office-2021-using-sccm-configmgr/

https://config.office.com/deploymentsettings

http://officedev.github.io/Office-IT-Pro-Deployment-Scripts/

https://docs.microsoft.com/en-us/deployoffice/ltsc2021/deploy