Add WindowsPackage - PowerShell


Overview

Add-WindowsPackage installs or updates Windows Provisioning packages (.ppkg files) on a local or remote computer. Provisioning packages are bundles of settings, configurations, and applications that can be used to customize a Windows 10 or Windows 11 operating system installation.

Syntax

Add-WindowsPackage [-Path] <String> [-Online] [-Force] [-DependsOn] <String[]> [-Parameters] <StringDictionary> [[-WhatIf] | [-Confirm]] [-DisableAutomaticReboot] [-Async] [-Credential <PSCredential>] [-FailureAction <AddWindowsPackageFailureAction>] [-Measure]

Options/Flags

  • -Path: Specifies the path to the provisioning package (.ppkg) file.
  • -Online: Installs the package online, downloading it from the Microsoft Store or Windows Update if necessary.
  • -Force: Ignores any existing package deployments and forces the installation of the specified package.
  • -DependsOn: Specifies a list of package dependencies that must be installed before the current package can be installed.
  • -Parameters: Specifies a dictionary of parameters that can be used to customize the package installation.
  • -WhatIf: Displays the actions that would be performed without actually installing the package.
  • -Confirm: Prompts the user to confirm the installation before executing it.
  • -DisableAutomaticReboot: Prevents the computer from automatically rebooting after the installation is completed.
  • -Async: Installs the package asynchronously, allowing the command to continue running while the installation is in progress.
  • -Credential: Specifies the credentials to use for the installation if the current user does not have sufficient privileges.
  • -FailureAction: Specifies the action to take if the package installation fails. Possible values: Continue, Ignore, Stop.
  • -Measure: Displays performance measurements for the installation operation.

Examples

Simple Installation:

Add-WindowsPackage -Path "C:\path\to\mypackage.ppkg"

Installation with Parameters:

Add-WindowsPackage -Path "C:\path\to\mypackage.ppkg" -Parameters @{"MyParameter1" = "Value1"; "MyParameter2" = "Value2"}

Installation as a Different User:

Add-WindowsPackage -Path "C:\path\to\mypackage.ppkg" -Credential (Get-Credential)

Common Issues

  • Package Dependencies: Ensure that any package dependencies are installed before attempting to install the package.
  • Admin Privileges: The command must be run with elevated privileges (as an administrator).
  • Network Connectivity: Online installations require an active internet connection.

Integration

Get the List of Installed Packages:

Get-WindowsPackage

Remove a Package:

Remove-WindowsPackage -PackageName <Package Name>

Related Commands

  • New-PackageInstaller
  • Get-PackageInstaller
  • Install-AppxPackage