Five years later, chatGPT produced for me the following powershell script, which takes an AppInstaller path as a parameter and installs it for all users:
# Define the path to the AppInstaller XML File
param([String]$xmlFilePath)
# Define the directory for downloads
$downloadDirectory = "C:\AppInstallerTemp"
cmd.exe /c mkdir $downloadDirectory
# Supresses slow powershell GUI
$ProgressPreference = 'SilentlyContinue'
# Load the XML file
$xml = [xml](Get-Content $xmlFilePath)
# Get the Uri for the MainBundle
$mainBundleUri = $xml.AppInstaller.MainBundle.Uri
# Define the XML namespace
$namespaceStr = $xml.AppInstaller.xmlns
$namespace = New-Object Xml.XmlNamespaceManager($xml.NameTable)
$namespace.AddNamespace("ns", $namespaceStr)
# Download the MainBundle
$mainBundleFileName = "MainBundle.msixbundle"
$mainBundlePath = "$downloadDirectory\$mainBundleFileName"
Invoke-WebRequest -Uri $mainBundleUri -OutFile $mainBundlePath
# Get the Uri for dependencies with ProcessorArchitecture="x64"
$dependencies = $xml.SelectNodes("//ns:Dependencies/ns:Package[@ProcessorArchitecture='x64']", $namespace)
# Download and get the dependency paths for installation
$dependencyPaths = @()
foreach ($dependency in $dependencies) {
$dependencyUri = $dependency.Uri
$dependencyFileName = ($dependencyUri -split '/')[-1]
$dependencyPath = "$downloadDirectory\$dependencyFileName"
Invoke-WebRequest -Uri $dependencyUri -OutFile $dependencyPath
$dependencyPaths += $dependencyPath
}
# Install the MainBundle and add dependencies to the dependency path list
Add-AppxProvisionedPackage -Online -PackagePath $mainBundlePath -DependencyPackagePath $dependencyPaths -SkipLicense
# Cleans up temp files
cmd.exe /c rd /s /q $downloadDirectory
# Forces install for other users
Get-AppXPackage -allusers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
Write-Host "Installation completed."