# 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
# Remove existing package Get-AppxPackage -Name "YourAppName" | Remove-AppxPackage # Then install new version Add-AppxPackage -Path "newapp.msixbundle" Solution: Install the signing certificate msixbundle install powershell
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 # Check admin rights for AllUsers if ($AllUsers