Skip to content

Script Parameters

Ryan Schultz edited this page Apr 8, 2025 · 1 revision

Script Parameters for M365 Apps Deployment Toolkit

This page provides a detailed reference for all parameters available in the Install-Microsoft365Apps.ps1 script, explaining their purpose, usage, and examples.

Parameter Overview

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.

Basic Parameters

-ConfigXMLPath

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"

-OfficeInstallDownloadPath

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"

-Restart

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

Installation Mode Parameters

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.

-Force

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

-UninstallExisting

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

-SkipIfInstalled

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

-DetectOnly

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

-Uninstall

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

Additional Features

-RemoveConsumerOffice

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

Parameter Combinations

Parameters can be combined to create custom installation scenarios. Here are some common combinations:

Clean Installation

Removes any existing Office products before installing:

.\Install-Microsoft365Apps.ps1 -UninstallExisting

Clean Installation with Consumer Removal

Removes both traditional Office products and consumer versions:

.\Install-Microsoft365Apps.ps1 -UninstallExisting -RemoveConsumerOffice

Installation with Restart

Installs Office and restarts the computer afterward:

.\Install-Microsoft365Apps.ps1 -Restart

Custom Configuration and Download Path

Specifies a custom configuration file and download location:

.\Install-Microsoft365Apps.ps1 -ConfigXMLPath "C:\Configs\special-config.xml" -OfficeInstallDownloadPath "D:\Downloads\Office"

Force Installation with Custom Path

Forces installation even if Office is detected, using a custom download path:

.\Install-Microsoft365Apps.ps1 -Force -OfficeInstallDownloadPath "D:\OfficeInstall"

Parameter Precedence

When multiple installation mode parameters are specified, they follow this precedence:

  1. -DetectOnly (highest priority)
  2. -Uninstall
  3. -Force
  4. -UninstallExisting
  5. -SkipIfInstalled (lowest priority)

If multiple parameters are specified, the highest priority one will take effect.

Exit Codes

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.

Logging

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.

Advanced Usage Scenarios

Deployment Test Mode

This mode checks if Office is installed without making any changes:

.\Install-Microsoft365Apps.ps1 -DetectOnly

Pre-Deployment Cleanup

This removes existing Office products without installing new ones:

.\Install-Microsoft365Apps.ps1 -ConfigXMLPath "config\uninstall-office365.xml" -Uninstall

Silent Installation for RMM Tools

This performs a completely silent installation with no user interface:

PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command "& {.\Install-Microsoft365Apps.ps1 -ConfigXMLPath 'config\install-office365.xml' -RemoveConsumerOffice}"

Best Practices

  1. Start with -DetectOnly to verify detection before actual installation
  2. Use -RemoveConsumerOffice on new machines that might have pre-installed Office
  3. Use default paths when possible to maintain consistency
  4. Consider -UninstallExisting for problematic machines with partial installations
  5. Use -Force sparingly and only when needed
  6. Always verify logs after deployment to identify any issues

Clone this wiki locally