-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRemoveAppx.ps1
More file actions
116 lines (103 loc) · 3.9 KB
/
RemoveAppx.ps1
File metadata and controls
116 lines (103 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
function Remove-Appx {
<#
.SYNOPSIS
Removes built-in Appx packages from Windows 10/11.
.DESCRIPTION
This function removes built-in Appx packages from Windows 10/11. It allows you to select which Appx packages to remove, or removes all specified packages by default.
The function also creates a backup of the registry keys related to Appx packages before making any changes.
.PARAMETER Select
If specified, a selection dialog will be presented to choose which Appx packages to remove. If not specified, all defined Appx packages will be removed.
#>
param(
[Parameter(Mandatory = $false)] [switch]$Select
)
# create Temp
[void][System.IO.Directory]::CreateDirectory("C:\Temp")
# Backup registry keys
reg export HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Applications C:\Temp\AppxPackages.reg /y
$AppxToRemove = @(
"Microsoft.BingWeather*"
"Microsoft.BingSearch*"
"Microsoft.BingNews*"
"Microsoft.Microsoft3DViewer*"
"Microsoft.MicrosoftSolitaireCollection*"
"Microsoft.MicrosoftStickyNotes*"
"Microsoft.MixedReality.Portal*"
"Microsoft.MSPaint*"
"Microsoft.Paint*"
"Microsoft.Office.OneNote*"
"Microsoft.OutlookForWindows*"
"Microsoft.MicrosoftOfficeHub*"
"Microsoft.People*"
"Microsoft.ScreenSketch*"
"Microsoft.SkypeApp*"
"Microsoft.StorePurchaseApp*"
"Microsoft.Wallet*"
"Microsoft.WindowsAlarms*"
"Microsoft.WindowsCamera*"
"Microsoft.windowscommunicationsapps*"
"Microsoft.WindowsFeedbackHub*"
"Microsoft.WindowsMaps*"
"Microsoft.Windows.DevHome*"
"MicrosoftWindows.CrossDevice*"
"Microsoft.WindowsSoundRecorder*"
"Microsoft.Xbox.TCUI*"
"Microsoft.XboxApp*"
"Microsoft.XboxGameOverlay*"
"Microsoft.XboxGamingOverlay*"
"Microsoft.XboxIdentityProvider*"
"Microsoft.XboxSpeechToTextOverlay*"
"Microsoft.YourPhone*"
"Microsoft.ZuneMusic*"
"Microsoft.ZuneVideo*"
"Microsoft.GetHelp*"
"Microsoft.Todos*"
"Microsoft.Copilot*"
"Microsoft.PowerAutomateDesktop*"
"MicrosoftCorporationII.QuickAssist*"
"*Clipchamp.Clipchamp*"
)
# Check if Appx is installed
$AppxFound = @()
foreach ($Entry in $AppxToRemove) {
if (Get-AppxPackage -AllUsers -Name $Entry) {
$Appx = Get-AppxPackage -AllUsers -Name $Entry
$AppxFound += $Appx[0].Name
}
}
# if -Select
if ($Select) {
$AppxList = $AppxFound | Out-GridView -Title "Select Appx to remove:" -OutputMode Multiple
}
else {
$AppxList = $AppxFound
}
# delete biult-in Appx
foreach ($Appx in $AppxList) {
try {
Get-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Applications\$Appx*" | Remove-Item -Recurse -Force
Get-AppxPackage -AllUsers -Name $Appx | Remove-AppxPackage -AllUsers
if (!(Get-AppxPackage -AllUsers -Name $Appx)) {
Write-Host "$Appx - Removed" -ForegroundColor Green
}
else {
Write-Host "$Appx - Failed" -ForegroundColor Red
}
}
catch {
Write-Host "$Appx - Failed" -ForegroundColor Red
}
}
# Save error log
if ($Error.Count -ne 0) {
$DateTime = Get-Date -Format "dd.MM.yyyy HH:mm"
foreach ($Entry in $Error) {
Add-Content -Value "$DateTime - $env:computername - $Entry" -Path "~\Desktop\ErrorLog.log" -Force
$Line = '-' * '60'
Write-Output "`n$Line`n" | Out-Host
Write-Output "AN ERROR OCCURED. SEE THE ERROR LOG ON THE DESKTOP" | Out-Host
Write-Output "`n$Line`n" | Out-Host
}
}
}
Remove-Appx -Select