Reworked text output

This commit is contained in:
Yorick Barbanneau 2018-02-22 12:39:09 +01:00
parent 539c0aeae3
commit 4debcb2e36

View file

@ -9,7 +9,7 @@ $ErrorActionPreference = "SilentlyContinue"
function block_shitty_host { function block_shitty_host {
param([string]$filename, [string]$ip, [string]$hostname) param([string]$filename, [string]$ip, [string]$hostname)
remove-host $filename $hostname remove-host $filename $hostname
Write-Host -NoNewline -ForegroundColor White "Block host $hostname : " Write-Host -NoNewline "`t$hostname :"
try { try {
if ( ! $(is_host_present $filename $hostname) ){ if ( ! $(is_host_present $filename $hostname) ){
$ip + "`t`t" + $hostname | Out-File -encoding ASCII -append $filename $ip + "`t`t" + $hostname | Out-File -encoding ASCII -append $filename
@ -41,7 +41,7 @@ function is_host_present {
function block_shitty_ip { function block_shitty_ip {
param($ip) param($ip)
Write-Host -ForegroundColor white -NoNewline "Blacklist IP $ip : " Write-Host -NoNewline "`t$ip : "
if ( Get-NetFirewallRule -Name Blacklist_$ip -ErrorAction SilentlyContinue) { if ( Get-NetFirewallRule -Name Blacklist_$ip -ErrorAction SilentlyContinue) {
Write-Host -ForegroundColor Yellow "already blacklisted" Write-Host -ForegroundColor Yellow "already blacklisted"
return return
@ -61,7 +61,7 @@ function block_shitty_ip {
function remove_shitty_tasks () { function remove_shitty_tasks () {
param($taskList) param($taskList)
Foreach ($task in $taskList){ Foreach ($task in $taskList){
Write-Host -ForegroundColor white -NoNewline "Remove Task $task : " Write-Host -NoNewline "`t$task : "
if ($PSVersionTable.PSVersion.Major -gt 2) { if ($PSVersionTable.PSVersion.Major -gt 2) {
if (Get-ScheduledTask -TaskName $task -ErrorAction SilentlyContinue) { if (Get-ScheduledTask -TaskName $task -ErrorAction SilentlyContinue) {
Write-Host -NoNewline -ForegroundColor DarkGreen "found! " Write-Host -NoNewline -ForegroundColor DarkGreen "found! "
@ -75,7 +75,7 @@ function remove_shitty_tasks () {
else { Write-Host -ForegroundColor Yellow "already removed"} else { Write-Host -ForegroundColor Yellow "already removed"}
} }
else { else {
Write-Host -Nonewline -ForegroundColor Red "damned! this is not Windows 10!" Write-Host -ForegroundColor Red "damned! this is not Windows 10!"
} }
} }
} }
@ -89,7 +89,7 @@ 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 -NoNewline "`t$key reg key to $value : " Write-Host -NoNewline "`t$key reg key to $value : "
if (!(Test-Path $path)){ if (!(Test-Path $path)){
Write-Host -ForegroundColor Gray -NoNewline "creating path " Write-Host -NoNewline "creating path "
New-Item -Path $path -Force | Out-Null New-Item -Path $path -Force | Out-Null
} }
@ -118,7 +118,7 @@ function modify_shitty_reg_value {
# $name : Feature name # $name : Feature name
function disable_shitty_feature { function disable_shitty_feature {
param ($name) param ($name)
Write-Host -NoNewline -ForegroundColor White "Disable $name feature : " Write-Host -NoNewline "`t$name : "
$requestInstall = dism /online /Get-FeatureInfo /FeatureName:$name /English $requestInstall = dism /online /Get-FeatureInfo /FeatureName:$name /English
$isInstalled = $requestInstall | Select-String "state" $isInstalled = $requestInstall | Select-String "state"
If ($isInstalled -match "Enable") { If ($isInstalled -match "Enable") {
@ -141,7 +141,7 @@ function disable_shitty_feature {
# $pkg : Package (Object) # $pkg : Package (Object)
function remove_shitty_modern_app { function remove_shitty_modern_app {
param($pkg) param($pkg)
Write-Host -ForegroundColor white -NoNewLine "Remove $($pkg.Name) modern app : " Write-Host -NoNewLine "$($pkg.Name) :"
try { try {
$pkg | Remove-AppxPackage $pkg | Remove-AppxPackage
} }
@ -155,7 +155,7 @@ function remove_shitty_modern_app {
function remove_provisioned_shitty_modern_app { function remove_provisioned_shitty_modern_app {
param($pkg) param($pkg)
Write-Host -ForegroundColor white -NoNewline "remove provisioned $($pkg.DisplayName) : " Write-Host -NoNewline "`t$($pkg.DisplayName) : "
try { try {
$pkg | Remove-AppxProvisionedPackage -Online | Out-Null $pkg | Remove-AppxProvisionedPackage -Online | Out-Null
} }
@ -168,10 +168,10 @@ function remove_provisioned_shitty_modern_app {
} }
function disable_shitty_service ([string]$name){ function disable_shitty_service ([string]$name){
Write-Host -ForegroundColor White -NoNewline "Disable service $name : " Write-Host -NoNewline "`t$name : "
$serv = Get-Service -name $name $serv = Get-Service -name $name
if ( !$serv) { if ( !$serv) {
Write-Host -ForegroundColor Red "not found " Write-Host -ForegroundColor Red "not found"
return return
} }
if ( $serv.StartType -eq "Disable") { if ( $serv.StartType -eq "Disable") {
@ -188,7 +188,7 @@ function disable_shitty_service ([string]$name){
# $process : name of process to kill (String) # $process : name of process to kill (String)
function kill_shitty_process { function kill_shitty_process {
param([string]$process) param([string]$process)
Write-Host -ForegroundColor white -NoNewLine "`tKilling $process : " Write-Host -NoNewLine "`tKilling $process : "
try { try {
$p = Get-Process $process $p = Get-Process $process
Stop-Process $p | Out-Null Stop-Process $p | Out-Null
@ -202,13 +202,21 @@ function kill_shitty_process {
Write-Output "`nI's time to kick ass and chew bubble gum" Write-Output "`nI's time to kick ass and chew bubble gum"
Write-Output "________________________________________`n" Write-Output "________________________________________`n"
Write-Host -ForegroundColor White "Blacklist hosts :"
foreach ($line in Get-Content "lib\hosts.txt"){ block_shitty_host $HOST_FILE $HOST_IP $line } foreach ($line in Get-Content "lib\hosts.txt"){ block_shitty_host $HOST_FILE $HOST_IP $line }
Write-Host -ForegroundColor White "`nBlacklist IPs :"
foreach ($line in Get-Content "lib\ip.txt"){ block_shitty_ip $line } foreach ($line in Get-Content "lib\ip.txt"){ block_shitty_ip $line }
Write-Host -ForegroundColor White "`nDisable features :"
foreach ($line in Get-Content "lib\features.txt"){ disable_shitty_feature $line } foreach ($line in Get-Content "lib\features.txt"){ disable_shitty_feature $line }
Write-Host -ForegroundColor White "`nDisable services :"
foreach ($line in Get-Content "lib\services.txt") { disable_shitty_featureService $line } foreach ($line in Get-Content "lib\services.txt") { disable_shitty_featureService $line }
Write-Host -ForegroundColor White "`nRemove modern apps :"
Get-AppxPackage -AllUsers | Where-Object { $_.name -in $(Get-Content "lib\apps.txt")} | foreach { Get-AppxPackage -AllUsers | Where-Object { $_.name -in $(Get-Content "lib\apps.txt")} | foreach {
remove_shitty_modern_app $_ remove_shitty_modern_app $_
} }
Write-Host -ForegroundColor White "`nRemove provisioned modern apps :"
Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -in $(Get-Content "lib\apps.txt")} | foreach { Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -in $(Get-Content "lib\apps.txt")} | foreach {
remove_provisioned_shitty_modern_app $_ remove_provisioned_shitty_modern_app $_
} }
@ -216,13 +224,13 @@ Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -in $(Get-Con
foreach ($line in Get-Content "lib\tasks.txt") {remove_shitty_tasks $line } foreach ($line in Get-Content "lib\tasks.txt") {remove_shitty_tasks $line }
#Remove all OneDrive Stuff thanks to https://github.com/W4RH4WK/Debloat-Windows-10/ #Remove all OneDrive Stuff thanks to https://github.com/W4RH4WK/Debloat-Windows-10/
Write-Host -ForegroundColor white "Removing all Onedrive stuff :" Write-Host -ForegroundColor white "`nRemoving all Onedrive stuff :"
# Kill onedrive qnd explorer for proper uninstallation # Kill onedrive qnd explorer for proper uninstallation
kill_shitty_process "onedrive" kill_shitty_process "onedrive"
kill_shitty_process "explorer" kill_shitty_process "explorer"
Write-Host -ForegroundColor White "`tUninstalling Onedrive" Write-Host "`tUninstalling Onedrive"
if (Test-Path "$env:systemroot\System32\OneDriveSetup.exe") { if (Test-Path "$env:systemroot\System32\OneDriveSetup.exe") {
& "$env:systemroot\System32\OneDriveSetup.exe" /uninstall & "$env:systemroot\System32\OneDriveSetup.exe" /uninstall
} }
@ -233,7 +241,7 @@ Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$env:localappdata\Mic
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$env:programdata\Microsoft OneDrive" Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$env:programdata\Microsoft OneDrive"
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$env:systemdrive\OneDriveTemp" Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$env:systemdrive\OneDriveTemp"
Write-Host -ForegroundColor White "`tModify OneDrive shitty registery values :" Write-Host "`tModify OneDrive shitty registery values :"
#OneDrive #OneDrive
modify_shitty_reg_value "HKLM:\Software\Policies\Microsoft\Windows\OneDrive" "DisableFileSyncNGSC" 1 modify_shitty_reg_value "HKLM:\Software\Policies\Microsoft\Windows\OneDrive" "DisableFileSyncNGSC" 1
modify_shitty_reg_value "HKLM:\Software\Policies\Microsoft\Windows\OneDrive" "DisableFileSync" 1 modify_shitty_reg_value "HKLM:\Software\Policies\Microsoft\Windows\OneDrive" "DisableFileSync" 1
@ -246,25 +254,25 @@ Remove-PSDrive -Name HKCR
Start-Process "explorer.exe" Start-Process "explorer.exe"
#Advertiging... #Advertiging...
Write-Host -ForegroundColor White "Disable Advertising :" Write-Host -ForegroundColor White "`nDisable Advertising :"
modify_shitty_reg_value "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\AdvertisingInfo" "Enabled" "0" modify_shitty_reg_value "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\AdvertisingInfo" "Enabled" "0"
modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo" "DisabledByGroupPolicy" 1 modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo" "DisabledByGroupPolicy" 1
# Geoloc. # Geoloc.
Write-Host -ForegroundColor White "Disable Geolocalization :" Write-Host -ForegroundColor White "`nDisable Geolocalization :"
modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors" "DisableLocation" 1 modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors" "DisableLocation" 1
modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors" "DisableLocationScripting" 1 modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors" "DisableLocationScripting" 1
modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors" "DisableWindowsLocationProvider" 1 modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors" "DisableWindowsLocationProvider" 1
#smartscreen filter #smartscreen filter
Write-Host -ForegroundColor White "Disable Smartscreen filter :" Write-Host -ForegroundColor White "`nDisable Smartscreen filter :"
modify_shitty_reg_value "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost" "EnableWebContentEvaluation" modify_shitty_reg_value "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost" "EnableWebContentEvaluation"
# AllowTelemetry # AllowTelemetry
Write-Host -ForegroundColor White "Disable Telemetry :" Write-Host -ForegroundColor White "`nDisable Telemetry :"
modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" "AllowTelemetry" 0 modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" "AllowTelemetry" 0
Write-Host -ForegroundColor White "Modify somes Windows defendenr behaviors :" Write-Host -ForegroundColor White "`nModify somes Windows defendenr behaviors :"
# Windows Defender Delivery Optimization Download # Windows Defender Delivery Optimization Download
modify_shitty_reg_value "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" "DODownloadMode" "0" modify_shitty_reg_value "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" "DODownloadMode" "0"
# Windows Defender Behavior monitoring and Spynet reporting. # Windows Defender Behavior monitoring and Spynet reporting.
@ -273,7 +281,7 @@ modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spyn
modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" "SubmitSamplesConsent" 2 modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" "SubmitSamplesConsent" 2
Write-Host -ForegroundColor White "Disable Wifi-Sense :" Write-Host -ForegroundColor White "`nDisable Wifi-Sense :"
# WifiSense Credential Share # WifiSense Credential Share
modify_shitty_reg_value "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\features" "WiFiSenseCredShared" "0" modify_shitty_reg_value "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\features" "WiFiSenseCredShared" "0"
# WifiSense Open-ness # WifiSense Open-ness
@ -281,12 +289,12 @@ modify_shitty_reg_value "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\feat
# Disable Cortana # Disable Cortana
Write-Host -ForegroundColor White "Disable Cortana (online at least) :" Write-Host -ForegroundColor White "`nDisable Cortana (online at least) :"
modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search\" "AllowCortana" "0" modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search\" "AllowCortana" "0"
modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search\" "ConnectedSearchUseWeb" "0" modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search\" "ConnectedSearchUseWeb" "0"
# App right. # App right.
Write-Host -ForegroundColor White "Disable rights for applications :" Write-Host -ForegroundColor White "`nDisable rights for applications :"
modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsAccessAccountInfo" 2 modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsAccessAccountInfo" 2
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
@ -302,11 +310,11 @@ modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "
modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsSyncWithDevices" 2 modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" "LetAppsSyncWithDevices" 2
# MS Account # MS Account
Write-Host -ForegroundColor White "Disable MS online account for login :" Write-Host -ForegroundColor White "`nDisable MS online account for login :"
modify_shitty_reg_value "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" "NoConnectedUser" 3 modify_shitty_reg_value "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" "NoConnectedUser" 3
# App suggestion (Cloud Content) # App suggestion (Cloud Content)
Write-Host -ForegroundColor White "Disable suggestions :" Write-Host -ForegroundColor White "`nDisable suggestions :"
modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Cloud Content" "DisableWindowsConsumerFeatures" 1 modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Cloud Content" "DisableWindowsConsumerFeatures" 1
Write-Host "all done!" Write-Host "all done!"