From d2a268ad6ca38fe1c3ca1b1f8437fd576a8240e9 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Fri, 26 Jan 2018 18:04:02 +0100 Subject: [PATCH] Rewrite disable_shitty_modern_app for better output --- cleanW10.ps1 | 58 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/cleanW10.ps1 b/cleanW10.ps1 index b430723..6bbdf82 100644 --- a/cleanW10.ps1 +++ b/cleanW10.ps1 @@ -54,7 +54,7 @@ function block_shitty_ip { Write-Host -Nonewline -ForegroundColor Red " Error " return } - } + } } function remove_shitty_tasks () { @@ -80,10 +80,10 @@ function remove_shitty_tasks () { } # Modify a reg value -# Params : +# Params : # path : the complete path to reg key # key : key name -# value : The value to write +# value : The value to write function modify_shitty_reg_value { param([string]$path, [string]$key, [string]$value, [string]$type) 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 " New-Item -Path $path -Force | Out-Null } - + try { - if ($type) { - Set-ItemProperty -Path $path -Name $key -Value $value -Type $type -Force + if ($type) { + Set-ItemProperty -Path $path -Name $key -Value $value -Type $type -Force } 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]{ @@ -140,19 +140,35 @@ 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" - 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 - } - catch { - Write-Host -ForegroundColor Red " Error " - return - } - Write-Host -ForegroundColor Green " Done " + Write-Host -ForegroundColor white -NoNewLine "Remove $name modern app" + $package = Get-AppxPackage -AllUsers -name *$name* + if ( $package ) { + 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"} + + 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){ @@ -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" "LetAppsAccessCallHistory" 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" "LetAppsAccessLocation" 2 modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsAccessMessaging" 2