Created
January 28, 2025 14:40
-
-
Save echu2013/5aa416d4269d50e4d5edcaf01cb00acb to your computer and use it in GitHub Desktop.
Removes Appx installed for users but not provisioned system-wide, which prevents Sysprep correct operation
This file contains hidden or 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 | |
# Now you can launch sysprep |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment