Compare commits
2 commits
e85b87fb15
...
576851de0c
Author | SHA1 | Date | |
---|---|---|---|
576851de0c | |||
4650f48ee3 |
1 changed files with 61 additions and 62 deletions
107
cleanW10.ps1
107
cleanW10.ps1
|
@ -9,21 +9,21 @@ $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 shitty host $hostname"
|
Write-Host -NoNewline -ForegroundColor White "Block host $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
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Host -ForegroundColor Yellow " Already blocked "
|
Write-Host -ForegroundColor Yellow "already blocked "
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host -ForegroundColor Red " Error "
|
Write-Host -ForegroundColor Red "error"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Write-Host -ForegroundColor Green " done "
|
Write-Host -ForegroundColor Green "done"
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_host_present {
|
function is_host_present {
|
||||||
|
@ -43,7 +43,7 @@ function block_shitty_ip {
|
||||||
param($ip)
|
param($ip)
|
||||||
Write-Host -ForegroundColor white -NoNewline "Blacklist IP $ip : "
|
Write-Host -ForegroundColor white -NoNewline "Blacklist IP $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
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -51,31 +51,31 @@ function block_shitty_ip {
|
||||||
New-NetFirewallRule -Name Blacklist_$ip -DisplayName "BlackList $ip" -Protocol any -Enabled True -Profile Any -RemoteAddress $ip -Action Block | Out-Null
|
New-NetFirewallRule -Name Blacklist_$ip -DisplayName "BlackList $ip" -Protocol any -Enabled True -Profile Any -RemoteAddress $ip -Action Block | Out-Null
|
||||||
}
|
}
|
||||||
Catch {
|
Catch {
|
||||||
Write-Host -Nonewline -ForegroundColor Red " Error "
|
Write-Host -ForegroundColor Red "error"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Write-Host -ForegroundColor Green " Done"
|
Write-Host -ForegroundColor Green "done"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 -ForegroundColor white -NoNewline "Remove Task $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! "
|
||||||
Write-Host -Nonewline -ForegroundColor white "removing ... "
|
Write-Host -Nonewline -ForegroundColor white "removing : "
|
||||||
Try {Unregister-ScheduledTask -TaskName $task -ErrorAction SilentlyContinue -Confirm:$false}
|
Try {Unregister-ScheduledTask -TaskName $task -ErrorAction SilentlyContinue -Confirm:$false}
|
||||||
Catch {
|
Catch {
|
||||||
Write-Host -Nonewline -ForegroundColor Red " Error "
|
Write-Host -Nonewline -ForegroundColor Red "error"
|
||||||
}
|
}
|
||||||
Write-Host -ForegroundColor Green " Done"
|
Write-Host -ForegroundColor Green "done"
|
||||||
}
|
}
|
||||||
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 -Nonewline -ForegroundColor Red "damned! this is not Windows 10!"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,9 +87,9 @@ function remove_shitty_tasks () {
|
||||||
# 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 : "
|
||||||
if (!(Test-Path $path)){
|
if (!(Test-Path $path)){
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,15 +102,15 @@ function modify_shitty_reg_value {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch [System.Security.SecurityException]{
|
catch [System.Security.SecurityException]{
|
||||||
Write-Host -ForegroundColor Red "Access denied"
|
Write-Host -ForegroundColor Red "access denied"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host -ForegroundColor Red " Error "
|
Write-Host -ForegroundColor Red "error "
|
||||||
Write-Host $Error[0]
|
Write-Host $Error[0]
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Write-host -ForegroundColor Green " done "
|
Write-host -ForegroundColor Green "done "
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to remove shitty prog from shitty win
|
# Function to remove shitty prog from shitty win
|
||||||
|
@ -126,78 +126,77 @@ function disable_shitty_feature {
|
||||||
Dism /online /Disable-Feature /FeatureName:$name /NoRestart | Out-Null
|
Dism /online /Disable-Feature /FeatureName:$name /NoRestart | Out-Null
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host -ForegroundColor Red " Error"
|
Write-Host -ForegroundColor Red "error"
|
||||||
Return
|
Return
|
||||||
}
|
}
|
||||||
Write-Host -ForegroundColor Green " done "
|
Write-Host -ForegroundColor Green "done "
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Host -ForegroundColor Yellow " already disable "
|
Write-Host -ForegroundColor Yellow "already disable "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# disable "Modern App"
|
# remove unwanted "Modern App"
|
||||||
# Params
|
# Params
|
||||||
# $name : Name of modern app
|
# $pkg : Package (Object)
|
||||||
function disable_shitty_modern_app {
|
function remove_shitty_modern_app {
|
||||||
param([string]$name)
|
param($pkg)
|
||||||
Write-Host -ForegroundColor white -NoNewLine "Remove $name modern app"
|
Write-Host -ForegroundColor white -NoNewLine "Remove $($pkg.Name) modern app : "
|
||||||
$package = Get-AppxPackage -AllUsers -name *$name*
|
|
||||||
if ( $package ) {
|
|
||||||
Write-Host -ForegroundColor white -NoNewLine " installed :"
|
|
||||||
try {
|
try {
|
||||||
$package | Remove-AppxPackage
|
$pkg | Remove-AppxPackage
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host -ForegroundColor Red " Uninstall error"
|
Write-Host -ForegroundColor Red "error"
|
||||||
|
write-Host $Error[0]
|
||||||
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 " |"
|
function remove_provisioned_shitty_modern_app {
|
||||||
$provisioned = Get-AppxProvisionedPackage -Online | where-Object {$_.PackageName -like "*$name*"}
|
param($pkg)
|
||||||
if ( $provisioned ) {
|
Write-Host -ForegroundColor white -NoNewline "remove provisioned $($pkg.DisplayName) : "
|
||||||
Write-Host -ForegroundColor White -NoNewLine " Provisonned"
|
|
||||||
try {
|
try {
|
||||||
$provisioned | Remove-AppxProvisionedPackage -Online | Out-Null
|
$pkg | Remove-AppxProvisionedPackage -Online | Out-Null
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host -ForegroundColor red " Error"
|
Write-Host -ForegroundColor red "error"
|
||||||
|
Write-Host $Error[0]
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Write-Host -ForegroundColor Green " Done"
|
Write-Host -ForegroundColor Green "done"
|
||||||
}
|
|
||||||
else { Write-Host -ForegroundColor Yellow " Not provisionned"}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function disable_shitty_service ([string]$name){
|
function disable_shitty_service ([string]$name){
|
||||||
Write-Host -ForegroundColor White -NoNewline "Disable service $name :"
|
Write-Host -ForegroundColor White -NoNewline "Disable service $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") {
|
||||||
Write-Host -ForegroundColor Yellow " Already disabled"
|
Write-Host -ForegroundColor Yellow "already disabled"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
service Stop-Service -InputObject $serv -PassThru | Set-Service -StartupType disabled
|
service Stop-Service -InputObject $serv -PassThru | Set-Service -StartupType disabled
|
||||||
Write-Host -ForegroundColor Green " Done "
|
Write-Host -ForegroundColor Green "done "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Output ""
|
Write-Output "`nI's time to kick ass and chew bubble gum"
|
||||||
Write-Output "I's time to kick ass and chew bubble gum"
|
Write-Output "________________________________________`n"
|
||||||
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\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\ip.txt"){ block_shitty_ip $line }
|
||||||
foreach ($line in Get-Content "lib\features.txt"){ disable_shitty_feature $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\services.txt") { disable_shitty_featureService $line }
|
||||||
foreach ($line in Get-Content "lib\apps.txt") { disable_shitty_modern_app $line }
|
Get-AppxPackage -AllUsers | Where-Object { $_.name -in $(Get-Content "lib\apps.txt")} | foreach {
|
||||||
|
remove_shitty_modern_app $_
|
||||||
|
}
|
||||||
|
Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -in $(Get-Content "lib\apps.txt")} | foreach {
|
||||||
|
remove_provisioned_shitty_modern_app $_
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($line in Get-Content "lib\tasks.txt") {remove_shitty_tasks $line }
|
foreach ($line in Get-Content "lib\tasks.txt") {remove_shitty_tasks $line }
|
||||||
|
|
||||||
|
|
||||||
|
@ -251,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
|
||||||
|
|
Reference in a new issue