MSIX PowerShell Cmdlets
MSIX uses the same PowerShell cmdlets available for AppX
packages. But Microsoft added aliases for them not to create confusion
between the AppX and MSIX packages.
Let’s go through some of them with a few examples.
To install an MSIX from Powershell, run the command:
Add-AppPackage -path "C:\Caphyon\MyApp.msix"
The same command works for MSIX bundles as well:
Add-AppPackage -path “C:\Caphyon\MyBundle.msixbundle”
To remove an MSIX from PowerShell, you can use:
Remove-AppPackage -Package "Caphyon.MyApp_22.214.171.124_neutral__8wekyb3d8bbwe"
The removable package name is composed like Vendor.AppName_Version_Build_Hash, where Build can be neutral or X64. To remove the MSIX from all users, you can use:
Remove-AppPackage -Package "Caphyon.MyApp_126.96.36.199_neutral__8wekyb3d8bbwe" -AllUsers .
To remove it from all users you need to run the command as an administrator.
If you want to find additional information about a package, you can use
Get-AppPackage -name “Caphyon.MyApp”
This returns multiple fields, for example, the PackageFullName.You can use this to run the uninstall command mentioned above. If you want to find out all the MSIX/Appx packages installed, you can use Get-AppPackage, or you can use Get-AppPackage -User “Domain\Username” to get all the packages installed for a specific user.
By default, all the MSIX/Appx packages are installed in %ProgramFiles%\WindowsApps, but you can change that in a few simple steps. First, if you need, you can add a new Appx volume with Add-AppxVolume -Path "E:\WindowsApps".
It’s necessary to specify \WindowsApps after the volume you choose.
After you added the new Volume, you can set it as default using Set-AppxDefaultVolume -Volume E:\. Now all your MSIX/Appx packages are installed by default in E:\WindowsApps.
With the new volumes in place, you can move installed MSIX packages by using:
Move-AppPackage -Package "Caphyon.MyApp_188.8.131.52_neutral__8wekyb3d8bbwe" -Volume E:\
To dismount a volume you can use: Dismount-AppxVolume -Volume E:\.
To remove a volume use: Remove-AppxVolume -Volume E:\.
If you dismount a volume you cannot use the installed applications on that location
You cannot remove a volume if any user has applications left on that location. You must first move/remove them.
To run an application inside the MSIX container you can use the Invoke-CommandInDesktopPackage cmdlet.
If you want to launch cmd.exe in your container you can use:
Invoke-CommandInDesktopPackage -PackageFamilyName "Caphyon.SampleMSIXPackage_r21n0w1rc5s2y" -appid "SampleMSIXPackage" -command "cmd.exe" -preventbreakaway
To view the merged registry hive, you can open up regedit.exe inside the MSIX with:
Invoke-CommandInDesktopPackage -PackageFamilyName "Caphyon.SampleMSIXPackage_r21n0w1rc5s2y" -appid "SampleMSIXPackage" -command "regedit.exe" -preventbreakaway
To find out your MSIX AppID check out this blog
PowerShell Cmdlets for MSIX Shared Containers
Starting with Windows 10 build 21354, Microsoft introduced support for MSIX Shared Containers.
With this update, there are new cmdlets included on the list, these are:
Before we go into the implementation of these cmdlets, it is important to note that Shared Package Containers are simple XML files. These XMLs require a unique Package Family Name for each package that belongs in that container.
A container example could look something like this:
<?xml version="1.0" encoding="utf-8"?> <AppSharedPackageContainer Name="ContosoContainer"> <PackageFamily Name="Caphyon.WithoutImage_r21n0w1rc5s2y" /> <PackageFamily Name="Caphyon.TheImage_r21n0w1rc5s2y" /> </AppSharedPackageContainer>
To add a new shared container, the following cmdlet must be executed:
Add-AppSharedPackageContainer <path to XML>
To remove a shared container, you must execute the following cmdlet:
Remove-AppSharedPackageContainer -Name <name>
If we have a look at the example XML file above, the Name of the shared container would be ContosoContainter.
To get information about the shared package container, i.e. what packages are inside the shared package container -- we can use the following cmdlet:
To reset a container, use the Reset cmdlet :
Reset-AppSharedPackageContainer -Name <name>
The reset cmdlet destroys all the application data of the container, including the virtual files and registry keys.
Get-AppSharedPackageContainer -Name <name>
For more cmdlets, check this link.