Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Install Windows Apps Using Add-AppxPackage in PowerShell

The Add-AppxPackage cmdlet is a powerful tool in the Windows PowerShell environment that allows users to install or update app packages (.appx or .appxbundle) on Windows 10 and later versions. This cmdlet is particularly useful for developers testing their applications or for IT professionals managing app installations across multiple systems.

Understanding Add-AppxPackage

Add-AppxPackage is used to add a signed app package to a user account. It can be used to install applications that are not available through the Microsoft Store, such as custom enterprise apps or apps in development. This cmdlet requires administrative privileges to execute.

Prerequisites

Before using Add-AppxPackage, ensure you have:

  • Administrative access to the system.
  • The app package file (.appx or .appxbundle) you wish to install.
  • Any necessary certificate files if the app is not signed by a trusted certificate authority.

Examples

Example 1: Installing a Simple App Package

To install an app package, open PowerShell with administrative privileges and run the following command:

Add-AppxPackage -Path "C:\Path\To\Your\App.appx"

Replace "C:\Path\To\Your\App.appx" with the actual path to your app package file.

Example 2: Installing an App Package with Dependencies

If your app package has dependencies, you need to install those as well. Assuming you have all dependency packages in a folder, you can install them using:

$dependencies = Get-ChildItem -Path "C:\Path\To\Dependencies\"
foreach ($dependency in $dependencies) {
    Add-AppxPackage -Path $dependency.FullName
}
Add-AppxPackage -Path "C:\Path\To\Your\App.appx"

This script first installs all dependency packages before installing the main app package.

Example 3: Installing an App Package with a Certificate

If your app is not signed by a trusted certificate authority, you need to install the certificate first. Assuming you have a .cer file:

  1. Install the certificate:

    Import-Certificate -FilePath "C:\Path\To\Certificate.cer" -CertStoreLocation Cert:\LocalMachine\TrustedPeople
  2. Install the app package:

    Add-AppxPackage -Path "C:\Path\To\Your\App.appx"

Troubleshooting

  • Error: Deployment failed with HRESULT: 0x80073CF9
    This error often occurs due to missing dependencies or insufficient disk space. Ensure all dependencies are installed and there is enough space on the disk.

  • Error: The package could not be installed because resources it modifies are currently in use
    Close any applications that might be using the files the app package modifies and try again.

Conclusion

The Add-AppxPackage cmdlet is a versatile tool for managing app installations on Windows systems. By understanding how to use it effectively, you can streamline the deployment of applications, whether for development or enterprise purposes.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.