-
Notifications
You must be signed in to change notification settings - Fork 0
Script Parameters
This page provides a detailed reference for all parameters available in the Install-Microsoft365Apps.ps1 script, explaining their purpose, usage, and examples.
The M365 Apps Deployment Toolkit script supports multiple parameters that control its behavior. These parameters can be combined in various ways to create customized deployment scenarios.
Specifies the path to the XML configuration file that controls how Office is installed.
-
Default value:
"$PSScriptRoot\config\install-office365.xml" - Required: No
- Value type: String
-
Example:
.\Install-Microsoft365Apps.ps1 -ConfigXMLPath "C:\CustomConfigs\my-office-config.xml"
Specifies the directory where temporary installation files will be stored.
-
Default value:
"$env:TEMP\Office365Install" - Required: No
- Value type: String
-
Example:
.\Install-Microsoft365Apps.ps1 -OfficeInstallDownloadPath "D:\OfficeInstall"
If specified, the computer will restart after a successful installation.
- Default value: None (switch parameter)
- Required: No
- Value type: Switch
-
Example:
.\Install-Microsoft365Apps.ps1 -Restart
The script includes several parameters that determine how it handles installation scenarios. These parameters are designed to be mutually exclusive - you should generally use only one of these per execution.
Forces installation even if Office is already detected. Without this, the script will skip installation if Office products are detected.
- Default value: None (switch parameter)
- Required: No
- Value type: Switch
-
Example:
.\Install-Microsoft365Apps.ps1 -Force
Uninstalls existing Office products before installing. This is useful for performing a clean installation.
- Default value: None (switch parameter)
- Required: No
- Value type: Switch
-
Example:
.\Install-Microsoft365Apps.ps1 -UninstallExisting
Explicitly skips installation if any Office products are detected. This is the default behavior unless -Force or -UninstallExisting is specified.
- Default value: None (switch parameter)
- Required: No
- Value type: Switch
-
Example:
.\Install-Microsoft365Apps.ps1 -SkipIfInstalled
Only detects Office products and exits without performing installation. Useful for inventory or reporting purposes.
- Default value: None (switch parameter)
- Required: No
- Value type: Switch
-
Example:
.\Install-Microsoft365Apps.ps1 -DetectOnly
Runs the script in uninstallation mode, removing Office products instead of installing them. Typically used with an uninstall configuration file.
- Default value: None (switch parameter)
- Required: No
- Value type: Switch
-
Example:
.\Install-Microsoft365Apps.ps1 -ConfigXMLPath "config\uninstall-office365.xml" -Uninstall
Detects and removes consumer versions of Office that commonly come pre-installed on Windows devices before installing.
- Default value: None (switch parameter)
- Required: No
- Value type: Switch
-
Example:
.\Install-Microsoft365Apps.ps1 -RemoveConsumerOffice
Parameters can be combined to create custom installation scenarios. Here are some common combinations:
Removes any existing Office products before installing:
.\Install-Microsoft365Apps.ps1 -UninstallExistingRemoves both traditional Office products and consumer versions:
.\Install-Microsoft365Apps.ps1 -UninstallExisting -RemoveConsumerOfficeInstalls Office and restarts the computer afterward:
.\Install-Microsoft365Apps.ps1 -RestartSpecifies a custom configuration file and download location:
.\Install-Microsoft365Apps.ps1 -ConfigXMLPath "C:\Configs\special-config.xml" -OfficeInstallDownloadPath "D:\Downloads\Office"Forces installation even if Office is detected, using a custom download path:
.\Install-Microsoft365Apps.ps1 -Force -OfficeInstallDownloadPath "D:\OfficeInstall"When multiple installation mode parameters are specified, they follow this precedence:
-
-DetectOnly(highest priority) -Uninstall-Force-UninstallExisting-
-SkipIfInstalled(lowest priority)
If multiple parameters are specified, the highest priority one will take effect.
The script returns the following exit codes:
| Exit Code | Description |
|---|---|
| 0 | Success |
| 1 | General error |
| [Other] | Exit code from the Office Deployment Tool |
These exit codes can be used in scripting scenarios to determine if the installation was successful.
Regardless of which parameters are used, the script creates a log file in the system temp directory:
%TEMP%\Microsoft365Install_YYYYMMDD_HHMMSS.log
This log contains detailed information about the script's execution, including:
- Detection results
- Installation status
- Error messages
- Configuration details
The log file is valuable for troubleshooting and verification.
This mode checks if Office is installed without making any changes:
.\Install-Microsoft365Apps.ps1 -DetectOnlyThis removes existing Office products without installing new ones:
.\Install-Microsoft365Apps.ps1 -ConfigXMLPath "config\uninstall-office365.xml" -UninstallThis performs a completely silent installation with no user interface:
PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command "& {.\Install-Microsoft365Apps.ps1 -ConfigXMLPath 'config\install-office365.xml' -RemoveConsumerOffice}"-
Start with
-DetectOnlyto verify detection before actual installation -
Use
-RemoveConsumerOfficeon new machines that might have pre-installed Office - Use default paths when possible to maintain consistency
-
Consider
-UninstallExistingfor problematic machines with partial installations -
Use
-Forcesparingly and only when needed - Always verify logs after deployment to identify any issues