Rewrite disable_shitty_modern_app for better output

This commit is contained in:
Yorick Barbanneau 2018-01-26 18:04:02 +01:00
parent 3c3c5ed0c6
commit d2a268ad6c

View file

@ -140,20 +140,36 @@ function disable_shitty_feature {
# $name : Name of modern app
function disable_shitty_modern_app {
param([string]$name)
Write-Host -ForegroundColor white -NoNewline "Remove $name modern app"
Write-Host -ForegroundColor white -NoNewLine "Remove $name modern app"
$package = Get-AppxPackage -AllUsers -name *$name*
if ( $package ) {
Write-Host -ForegroundColor white -NoNewLine " installed :"
try {
$pkgname = Get-AppxPackage -allusers -name *$name*
if (Get-AppxPackage $pkgname.Name) {
Remove-AppxPackage $pkgname
}
Get-AppxProvisionedPackage -Online | where-Object {$_.PackageName -like "*$name*"} | Remove-AppxProvisionedPackage -Online | Out-Null
$package | Remove-AppxPackage
}
catch {
Write-Host -ForegroundColor Red " Error "
Write-Host -ForegroundColor Red " Uninstall error"
return
}
Write-Host -ForegroundColor Green -NoNewLine " uninstalled"
}
else { Write-Host -ForegroundColor Yellow -NoNewLine " Not installed"}
Write-Host -ForegroundColor white -NoNewLine " |"
$provisioned = Get-AppxProvisionedPackage -Online | where-Object {$_.PackageName -like "*$name*"}
if ( $provisioned ) {
Write-Host -ForegroundColor White -NoNewLine " Provisonned"
try {
$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"}
}
function disable_shitty_service ([string]$name){
Write-Host -ForegroundColor White -NoNewline "Disable service $name :"