speedup: batch appx removal (at cost of less user feedback)

This ESPECIALLY helps during a second run of the removal script,
where the result is almost instantaneous. Instead of
initializing the Remove-AppxPackage routine N times,
it only needs to do it once.

The downside is that we can't control feedback to the user on
the progress - and users frequently complain about hung
processes etc. There is SOME feedback coming from the
Remove-AppxPackage process - hopefully that will be enough.

I also ensured that -AllUsers packages were removed,
which was not done previously. If there was a reason for
NOT removing -AllUsers for the blacklist, then it can
be removed, but the DeBloat All function does remove
it, so to be consistent it seemed best to do the same here.

In terms of $NonRemovables - I had just added that but
on second thought, let the user be smarter than the computer.
The user now has the tools to detect if there are
conflicts with nonRemovables, so if they choose to
try to remove it anyway, don't prevent that.
The computer might be lying after all...
pull/138/head
Justin Luth 5 years ago
parent 445da40eaa
commit e45c1ae76d

@ -485,13 +485,15 @@ $CustomizeBlacklists.Add_Click( {
$RemoveBlacklist.Add_Click( {
$ErrorActionPreference = 'silentlycontinue'
Function DebloatBlacklist {
foreach ($Bloat in $global:Bloatware) {
Get-AppxPackage -Name $Bloat| Remove-AppxPackage
Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $Bloat | Remove-AppxProvisionedPackage -Online
Write-Host "Requested removal of $Bloat."
}
Write-Host "Requesting removal of $global:BloatwareRegex"
Write-Host "--- This may take a while - please be patient ---"
Get-AppxPackage | Where-Object Name -cmatch $global:BloatwareRegex | Remove-AppxPackage
Write-Host "...now starting the silent ProvisionedPackage bloatware removal..."
Get-AppxProvisionedPackage -Online | Where-Object DisplayName -cmatch $global:BloatwareRegex | Remove-AppxProvisionedPackage -Online
Write-Host "...and the final cleanup..."
Get-AppxPackage -AllUsers | Where-Object Name -cmatch $global:BloatwareRegex | Remove-AppxPackage
}
Write-Host "Removing Bloatware with a specific blacklist."
Write-Host "`n`n`n`n`n`n`n`n`n`n`n`n`n`n`n`n`nRemoving blacklisted Bloatware.`n"
DebloatBlacklist
Write-Host "Bloatware removed!"
})

Loading…
Cancel
Save