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

@ -54,7 +54,7 @@ function block_shitty_ip {
Write-Host -Nonewline -ForegroundColor Red " Error " Write-Host -Nonewline -ForegroundColor Red " Error "
return return
} }
} }
} }
function remove_shitty_tasks () { function remove_shitty_tasks () {
@ -80,10 +80,10 @@ function remove_shitty_tasks () {
} }
# Modify a reg value # Modify a reg value
# Params : # Params :
# path : the complete path to reg key # path : the complete path to reg key
# key : key name # key : key name
# value : The value to write # value : The value to write
function modify_shitty_reg_value { function modify_shitty_reg_value {
param([string]$path, [string]$key, [string]$value, [string]$type) param([string]$path, [string]$key, [string]$value, [string]$type)
Write-Host -ForegroundColor white -NoNewline "Modify $key reg value to $value :" Write-Host -ForegroundColor white -NoNewline "Modify $key reg value to $value :"
@ -91,13 +91,13 @@ function modify_shitty_reg_value {
Write-Host -ForegroundColor Gray -NoNewline " creating path " Write-Host -ForegroundColor Gray -NoNewline " creating path "
New-Item -Path $path -Force | Out-Null New-Item -Path $path -Force | Out-Null
} }
try { try {
if ($type) { if ($type) {
Set-ItemProperty -Path $path -Name $key -Value $value -Type $type -Force Set-ItemProperty -Path $path -Name $key -Value $value -Type $type -Force
} }
else { else {
Set-ItemProperty -Path $path -Name $key -Value $value -Type Dword -Force Set-ItemProperty -Path $path -Name $key -Value $value -Type Dword -Force
} }
} }
catch [System.Security.SecurityException]{ catch [System.Security.SecurityException]{
@ -140,19 +140,35 @@ function disable_shitty_feature {
# $name : Name of modern app # $name : Name of modern app
function disable_shitty_modern_app { function disable_shitty_modern_app {
param([string]$name) param([string]$name)
Write-Host -ForegroundColor white -NoNewline "Remove $name modern app" Write-Host -ForegroundColor white -NoNewLine "Remove $name modern app"
try { $package = Get-AppxPackage -AllUsers -name *$name*
$pkgname = Get-AppxPackage -allusers -name *$name* if ( $package ) {
if (Get-AppxPackage $pkgname.Name) { Write-Host -ForegroundColor white -NoNewLine " installed :"
Remove-AppxPackage $pkgname try {
} $package | Remove-AppxPackage
Get-AppxProvisionedPackage -Online | where-Object {$_.PackageName -like "*$name*"} | Remove-AppxProvisionedPackage -Online | Out-Null }
} catch {
catch { Write-Host -ForegroundColor Red " Uninstall error"
Write-Host -ForegroundColor Red " Error " return
return }
} Write-Host -ForegroundColor Green -NoNewLine " uninstalled"
Write-Host -ForegroundColor Green " Done " }
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){ function disable_shitty_service ([string]$name){
@ -234,7 +250,7 @@ modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "
modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsAccessCalendar" 2 modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsAccessCalendar" 2
modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsAccessCallHistory" 2 modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsAccessCallHistory" 2
modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsAccessCamera" 2 modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsAccessCamera" 2
modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsAccessContacts" 2 modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsAccessContacts" 2
modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsAccessEmail" 2 modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsAccessEmail" 2
modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsAccessLocation" 2 modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsAccessLocation" 2
modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsAccessMessaging" 2 modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsAccessMessaging" 2