This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# After trying several approches only, which in general tells you to launch sysprep several times or removing everything | |
# I found this the most precise way to do. | |
# Otherwise u are stuck with a try-and-error process which is time consuming (launch, view error, remove, retry, etc) | |
# Get APPX Provisioned system-wide | |
$pkgsprovisioned= Get-AppxProvisionedPackage -Online | |
# Get ALLUSERS APPX which are NOT provisioned system-wide and NonRemovable flag is False | |
$pkgs= Get-AppxPackage -AllUsers | Where-Object { $_.Name -notin $pkgsprovisioned.DisplayName -and $_.NonRemovable -eq $false} | |
# Remove those APPX | |
$pkgs | Remove-AppxPackage -ErrorAction SilentlyContinue |