Skip to content

Install MSIX Package

Overview

This script will attempt to install an MSIX/APPX package on a system if not already installed.

If this script is being used with a Group Policy startup script and UNC path, make sure that the computer objects which the Group Policy targets has access to the MSIX/APPX package file as well.

Usage

Download and run locally

  1. Download the script:
Terminal window
Invoke-WebRequest -Uri https://techdocsoffline.com/powershell-snippets/Install-MSIXPackage.ps1 -OutFile Install-MSIXPackage.ps1
  1. Run the script with administrative privileges

Script Details

Install-MSIXPackage.ps1
# =============================================================================
# Script Name: Install MSIX Package
# Version: 1.0.0
# =============================================================================
#
# DESCRIPTION:
# Installs an MSIX/APPX package on a system if not already installed
#
# PARAMETERS (required):
# -PackageName : The partial or full package name used to verify installation status
# -PackagePath : The local or remote UNC path of the source package to install
#
# SOURCE:
# https://techdocsoffline.com/powershell-snippets/install-msix-package/
#
# DISCLAIMER:
# This script is provided "AS IS" without warranties of any kind.
# Always review scripts from the internet before executing them.
#
# =============================================================================
param (
[Parameter(Mandatory = $true)]
[string]$PackageName,
[Parameter(Mandatory = $true)]
[string]$PackagePath
)
# Check if the script is running with administrative privileges
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)) {
Write-Host "This script must be run as an administrator." -ForegroundColor Red
exit
}
# Check for matching provisioned packages
$matchingPackages = Get-AppxProvisionedPackage -Online | Where-Object {
$_.PackageName -like "*$PackageName*"
}
if ($matchingPackages.Count -ge 1) {
Write-Host "Exiting! Package count is greater than or equal to 1, this could indicate the package is already provisioned."
Write-Host "Matching Packages:"
$matchingPackages
return
}
# Check if the package source exists
if (-not (Test-Path -Path $PackagePath)) {
Write-Host "Exiting! Package source does not exist at $PackagePath"
return
}
Write-Host "Installing package from $PackagePath..."
# Install the package
Add-AppxProvisionedPackage -Online -PackagePath $PackagePath -SkipLicense
Write-Host "Installation complete."

Parameters

Named ParameterDescriptionRequiredExample
PackageNameThe partial or full package name to verify successful installationYescom.owllabs.meetingowl.windows_4.7.1.143_x64__cb17j8khw3v66
PackagePathThe full local or remote UNC path of the package to installYes\\Server.Example.tld\Software\meeting_owl_desktop_4.7.1.143.msix

Examples

Terminal window
# Run the script
.\Install-MSIXPackage.ps1 -PackageName com.owllabs.meetingowl.windows_4.7.1.143_x64__cb17j8khw3v66 -PackagePath \\Server.Example.tld\Software\meeting_owl_desktop_4.7.1.143.msix
Installing package from \\Server.Example.tld\Software\meeting_owl_desktop_4.7.1.143.msix...
Path :
Online : True
RestartNeeded : False
Installation complete.