Reworked modern app uninstall

This commit is contained in:
Yorick Barbanneau 2018-02-05 17:11:29 +01:00
parent e85b87fb15
commit 4650f48ee3

View file

@ -136,40 +136,35 @@ function disable_shitty_feature {
} }
} }
# disable "Modern App" # remove unwanted "Modern App"
# Params # Params
# $name : Name of modern app # $pkg : Package (Object)
function disable_shitty_modern_app { function remove_shitty_modern_app {
param([string]$name) param($pkg)
Write-Host -ForegroundColor white -NoNewLine "Remove $name modern app" Write-Host -ForegroundColor white -NoNewLine "Remove $($pkg.Name) modern app"
$package = Get-AppxPackage -AllUsers -name *$name* try {
if ( $package ) { $pkg | Remove-AppxPackage
Write-Host -ForegroundColor white -NoNewLine " installed :"
try {
$package | Remove-AppxPackage
}
catch {
Write-Host -ForegroundColor Red " Uninstall error"
return
}
Write-Host -ForegroundColor Green -NoNewLine " uninstalled"
} }
else { Write-Host -ForegroundColor Yellow -NoNewLine " Not installed"} catch {
Write-Host -ForegroundColor Red " error"
write-Host $Error[0]
retur
}
Write-Host -ForegroundColor Green " done"
}
Write-Host -ForegroundColor white -NoNewLine " |" function remove_provisioned_shitty_modern_app {
$provisioned = Get-AppxProvisionedPackage -Online | where-Object {$_.PackageName -like "*$name*"} param($pkg)
if ( $provisioned ) { Write-Host -ForegroundColor white -NoNewline "remove provisioned $($pkg.DisplayName) : "
Write-Host -ForegroundColor White -NoNewLine " Provisonned" try {
try { $pkg | Remove-AppxProvisionedPackage -Online | Out-Null
$provisioned | Remove-AppxProvisionedPackage -Online | Out-Null
}
catch {
Write-Host -ForegroundColor red " Error"
return
}
Write-Host -ForegroundColor Green " Done"
} }
else { Write-Host -ForegroundColor Yellow " Not provisionned"} catch {
Write-Host -ForegroundColor red " error"
Write-Host $Error[0]
return
}
Write-Host -ForegroundColor Green " done"
} }
function disable_shitty_service ([string]$name){ function disable_shitty_service ([string]$name){
@ -197,7 +192,13 @@ foreach ($line in Get-Content "lib\hosts.txt"){ block_shitty_host $HOST_FILE $HO
foreach ($line in Get-Content "lib\ip.txt"){ block_shitty_ip $line } foreach ($line in Get-Content "lib\ip.txt"){ block_shitty_ip $line }
foreach ($line in Get-Content "lib\features.txt"){ disable_shitty_feature $line } foreach ($line in Get-Content "lib\features.txt"){ disable_shitty_feature $line }
foreach ($line in Get-Content "lib\services.txt") { disable_shitty_featureService $line } foreach ($line in Get-Content "lib\services.txt") { disable_shitty_featureService $line }
foreach ($line in Get-Content "lib\apps.txt") { disable_shitty_modern_app $line } Get-AppxPackage -AllUsers | Where-Object { $_.name -in $(Get-Content "lib\apps.txt")} | foreach {
remove_shitty_modern_app $_
}
Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -in $(Get-Content "lib\apps.txt")} | foreach {
remove_provisioned_shitty_modern_app $_
}
foreach ($line in Get-Content "lib\tasks.txt") {remove_shitty_tasks $line } foreach ($line in Get-Content "lib\tasks.txt") {remove_shitty_tasks $line }