# Install certificate to trusted store (requires admin) $cert = Get-AuthenticodeSignature -FilePath "app.msixbundle" Import-Certificate -FilePath $cert.SignerCertificate.Path -CertStoreLocation Cert:\LocalMachine\TrustedPeople # Full deployment script $bundlePath = "C:\Deployments\MyApp.msixbundle" Pre-installation checks Write-Host "Verifying system requirements..." -ForegroundColor Cyan if ([Environment]::OSVersion.Version.Major -lt 10) Write-Host "❌ Windows 10 or later required" -ForegroundColor Red exit 1
[string]$LogFile = "$env:TEMP\MSIX_Install.log" )
Write-Host "Checking bundle integrity..." -ForegroundColor Cyan $hash = Get-FileHash -Path $bundlePath -Algorithm SHA256 Write-Host "Bundle hash: $($hash.Hash)" try Write-Host "Installing bundle..." -ForegroundColor Cyan $result = Add-AppxPackage -Path $bundlePath -ErrorAction Stop -Verbose msixbundle install powershell
Install-MSIXBundle Method 4: Silent Installation for Deployment # Silent installation (no UI prompts) Add-AppxPackage -Path "app.msixbundle" -ForceApplicationShutdown With specific volume (for multi-user systems) Add-AppxPackage -Path "app.msixbundle" -Volume "C:" Staged installation (download then register) Add-AppxPackage -Path "app.msixbundle" -StageOnly Register-ActivationOnlyPackage -Path "app.msixbundle" Uninstalling MSIX Bundles # Uninstall by package name Get-AppxPackage -Name "YourAppName" | Remove-AppxPackage Uninstall for all users (requires admin) Get-AppxPackage -AllUsers -Name "YourAppName" | Remove-AppxPackage -AllUsers Uninstall by full package name Remove-AppxPackage -Package "YourAppPublisher.YourApp_1.0.0.0_x64__randomstring" Common Troubleshooting Error: "Deployment failed because no applicable package found" Solution: Check architecture compatibility
# Check admin rights for AllUsers if ($AllUsers -and (-not (New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) throw "Administrator privileges required for AllUsers installation" # Verify file exists if (-not (Test-Path $BundlePath)) throw "Bundle file not found: $BundlePath" # Check if already installed $bundleInfo = Get-AppxPackage -Name (Get-AppxPackageManifest -Path $BundlePath).Package.Identity.Name if ($bundleInfo) Write-Log "Package already installed. Version: $($bundleInfo.Version)" $response = Read-Host "Do you want to reinstall? (y/n)" if ($response -ne 'y') Write-Log "Installation cancelled by user" return # Perform installation if ($AllUsers) Write-Log "Installing for all users..." Add-AppxPackage -Path $BundlePath -AllUsers -ErrorAction Stop else Write-Log "Installing for current user..." Add-AppxPackage -Path $BundlePath -ErrorAction Stop Write-Log "Installation completed successfully" Write-Host "✅ Installation successful!" -ForegroundColor Green # Install certificate to trusted store (requires admin)
catch Write-Host "❌ Installation failed: $_" -ForegroundColor Red
<# .SYNOPSIS Installs an MSIX bundle with logging and error handling .DESCRIPTION Installs MSIX bundle with optional user context selection .PARAMETER BundlePath Path to the .msixbundle file .PARAMETER AllUsers Install for all users (requires admin) .PARAMETER LogFile Path to log installation details #> param( [Parameter(Mandatory=$true)] [ValidateScript(Test-Path $_)] [string]$BundlePath, msixbundle install powershell
[switch]$AllUsers,