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...
This commit is contained in:
Justin Luth 2019-05-30 09:36:59 +03:00
parent 445da40eaa
commit e45c1ae76d

View File

@ -485,13 +485,15 @@ $CustomizeBlacklists.Add_Click( {
$RemoveBlacklist.Add_Click( { $RemoveBlacklist.Add_Click( {
$ErrorActionPreference = 'silentlycontinue' $ErrorActionPreference = 'silentlycontinue'
Function DebloatBlacklist { Function DebloatBlacklist {
foreach ($Bloat in $global:Bloatware) { Write-Host "Requesting removal of $global:BloatwareRegex"
Get-AppxPackage -Name $Bloat| Remove-AppxPackage Write-Host "--- This may take a while - please be patient ---"
Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $Bloat | Remove-AppxProvisionedPackage -Online Get-AppxPackage | Where-Object Name -cmatch $global:BloatwareRegex | Remove-AppxPackage
Write-Host "Requested removal of $Bloat." 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 DebloatBlacklist
Write-Host "Bloatware removed!" Write-Host "Bloatware removed!"
}) })