-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppx Packages.ps1
39 lines (36 loc) · 1.13 KB
/
Appx Packages.ps1
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
##Get appx Packages
$Packages = Get-AppxPackage
##Create Your allowlist
$AllowList = @(
'*WindowsCalculator*',
'*Office.OneNote*',
'*Microsoft.net*',
'*MicrosoftEdge*',
'*WindowsStore*',
'*WindowsTerminal*',
'*WindowsNotepad*',
'*Paint*'
)
###Get All Dependencies
ForEach($Dependency in $AllowList){
(Get-AppxPackage -Name “$Dependency”).dependencies | ForEach-Object{
$NewAdd = "*" + $_.Name + "*"
if($_.name -ne $null -and $AllowList -notcontains $NewAdd){
$AllowList += $NewAdd
}
}
}
##View all applications not in your allowlist
ForEach($App in $Packages){
$Matched = $false
Foreach($Item in $AllowList){
If($App -like $Item){
$Matched = $true
break
}
}
###Nonremovable attribute does not exist before 1809, so if you are running this on an earlier build, remove “-and $app.NonRemovable -eq $false” rt; it attempts to remove everything
if($matched -eq $false -and $app.NonRemovable -eq $false){
Get-AppxPackage -AllUsers -Name $App.Name -PackageTypeFilter Bundle | Remove-AppxPackage -AllUsers
}
}