From 0906839d2904a862e8327441eb94e7c0b7e4751d Mon Sep 17 00:00:00 2001 From: Yorick Date: Fri, 6 Jan 2017 12:23:39 +0100 Subject: [PATCH] Add function block_shitty_ip for better output --- cleanW10.ps1 | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/cleanW10.ps1 b/cleanW10.ps1 index 3ab03d1..821154b 100644 --- a/cleanW10.ps1 +++ b/cleanW10.ps1 @@ -38,6 +38,24 @@ function is_host_present { return $false } +function block_shitty_ip { + param($ip) + Write-Host -ForegroundColor white -NoNewline "Blacklist IP $ip : " + if ( Get-NetFirewallRule -Name Blacklist_$ip) { + Write-Host -ForegroundColor Yellow "Already blacklisted" + return + } + else { + Try { + New-NetFirewallRule -Name Blacklist_$ip -DisplayName "BlackList $ip" -Protocol any -Enabled True -Profile Any -RemoteAddress $ip -Action Block | Out-Null + } + Catch { + Write-Host -Nonewline -ForegroundColor Red " Error " + return + } + } +} + function remove_shitty_tasks () { param($taskList) Foreach ($task in $taskList){ @@ -157,21 +175,12 @@ Write-Output "I's time to kick ass and chew bubble gum" Write-Output "________________________________________" write-Output "" -foreach ($line in Get-Content "lib\hosts.txt"){ - block_shitty_host $HOST_FILE $HOST_IP $line -} - -foreach ($line in Get-Content "lib\ip.txt"){ - New-NetFirewallRule -Name Blacklist_$line -DisplayName "BlackList $line" -Protocol any -Enabled True -Profile Any -RemoteAddress $line -Action Block | Out-Null - Write-Output "Shitty IP $_ banned." -} - -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\apps.txt") { disable_shitty_modern_app $line } -foreach ($line in Get-Content "lib\tasks.txt") {remove_shitty_tasks $line } +#foreach ($line in Get-Content "lib\hosts.txt"){ block_shitty_host $HOST_FILE $HOST_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\services.txt") { disable_shitty_featureService $line } +#foreach ($line in Get-Content "lib\apps.txt") { disable_shitty_modern_app $line } +#foreach ($line in Get-Content "lib\tasks.txt") {remove_shitty_tasks $line } # AllowTelemetry modify_shitty_reg_value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" "AllowTelemetry" "0"