How to use the command Add-AppxPackage (with examples)
- Windows
- December 25, 2023
The Add-AppxPackage
command is a PowerShell utility used to add a signed app package (.appx
, .msix
, .appxbundle
, and .msixbundle
) to a user account. It allows users to easily install and manage applications on their Windows devices.
Use case 1: Add an app package
Code:
Add-AppxPackage -Path path\to\package.msix
Motivation: The motivation for using this command is to install a specific app package on a Windows device. This can be useful when you want to add a new application or update an existing one.
Explanation:
-Path
: Specifies the path to the app package file (package.msix
) that you want to install. This argument is required.path\to\package.msix
: The actual file path of the app package you want to install.
Example output:
The command will install the app package specified by path\to\package.msix
on the Windows device. The output will display the installation progress and any relevant information, such as the installation location.
Use case 2: Add an app package with dependencies
Code:
Add-AppxPackage -Path path\to\package.msix -DependencyPath path\to\dependencies.msix
Motivation:
This example is useful when you have an app package that requires additional dependencies to be installed along with it. By specifying the -DependencyPath
argument, you can ensure that all necessary dependencies are installed together with the main app package.
Explanation:
-DependencyPath
: Specifies the path to the dependency app package file (dependencies.msix
) that should be installed along with the main app package. This argument is optional.path\to\dependencies.msix
: The actual file path of the dependency app package you want to install.
Example output: The command will install both the main app package and its dependencies on the Windows device. The output will display the installation progress for each package and any relevant information.
Use case 3: Install an app using the app installer file
Code:
Add-AppxPackage -AppInstallerFile path\to\app.appinstaller
Motivation:
This use case is handy when you have an app installer file (app.appinstaller
) that provides metadata and instructions for installing an app. Instead of manually installing the app package, this command will read the app installer file and handle the installation process.
Explanation:
-AppInstallerFile
: Specifies the path to the app installer file (app.appinstaller
) that contains the necessary information for installing the app. This argument is required.path\to\app.appinstaller
: The actual file path of the app installer file you want to use for installation.
Example output: The command will read the app installer file and install the app according to the instructions provided. The output will display the installation progress and any relevant information.
Use case 4: Add an unsigned package
Code:
Add-AppxPackage -Path path\to\package.msix -DependencyPath path\to\dependencies.msix -AllowUnsigned
Motivation:
This example is useful when you have an unsigned app package (package.msix
) that you want to install on a Windows device. By including the -AllowUnsigned
argument, you can bypass the requirement for app packages to be digitally signed.
Explanation:
-AllowUnsigned
: Allows the installation of unsigned app packages. This argument is optional.path\to\package.msix
: The file path of the unsigned app package you want to install.-DependencyPath
: Specifies the path to the dependency app package file (dependencies.msix
) that should be installed along with the main app package. This argument is optional.path\to\dependencies.msix
: The actual file path of the dependency app package you want to install.
Example output: The command will install both the main app package and its dependencies, even though the app package is unsigned. The output will display the installation progress and any relevant information.