From 5ed3bc2fa08b068bb4e0b85cbb3f0366b538d86f Mon Sep 17 00:00:00 2001 From: Richard Newton Date: Thu, 4 Oct 2018 19:42:20 -0700 Subject: [PATCH] New blacklist function and GUI prompt I added a new blacklist function called DebloatBlacklist which will only remove the specified bloatware in the array in the function. I also renamed the Start-Debloat function to DebloatAllApps since it seemed to remove absolutely everything related to the Microsoft Store (Any games, apps, etc). When you hit "Yes" in the first prompt, you will be asked if you want debloat via a blacklist or if you want to remove everything, in terms of apps. --- Windows10Debloater.ps1 | 341 +++++++++++++++++++++++++++-------------- 1 file changed, 225 insertions(+), 116 deletions(-) diff --git a/Windows10Debloater.ps1 b/Windows10Debloater.ps1 index d42dd6e..2da583d 100644 --- a/Windows10Debloater.ps1 +++ b/Windows10Debloater.ps1 @@ -11,13 +11,14 @@ Else { Write-Output "The folder 'C:\Windows10Debloater' doesn't exist. This folder will be used for storing logs created after the script runs. Creating now." Start-Sleep 1 New-Item -Path "C:\Windows10Debloater" -ItemType Directory + Write-Output "The folder C:\Windows10Debloater was successfully created." } Start-Transcript -OutputDirectory "C:\Windows10Debloater" -Add-Type -AssemblyName PresentationCore,PresentationFramework +Add-Type -AssemblyName PresentationCore, PresentationFramework -Function Start-Debloat { +Function DebloatAllApps { [CmdletBinding()] @@ -31,6 +32,78 @@ Function Start-Debloat { Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -NotMatch $WhitelistedApps} | Remove-AppxProvisionedPackage -Online } +Function DebloatBlacklist { + [CmdletBinding()] + + Param () + + $Bloatware = @( + + #Unnecessary Windows 10 AppX Apps + "Microsoft.BingNews" + "Microsoft.DesktopAppInstaller" + "Microsoft.GetHelp" + "Microsoft.Getstarted" + "Microsoft.Messaging" + "Microsoft.Microsoft3DViewer" + "Microsoft.MicrosoftOfficeHub" + "Microsoft.MicrosoftSolitaireCollection" + "Microsoft.NetworkSpeedTest" + "Microsoft.Office.OneNote" + "Microsoft.Office.Sway" + "Microsoft.OneConnect" + "Microsoft.People" + "Microsoft.Print3D" + "Microsoft.RemoteDesktop" + "Microsoft.SkypeApp" + "Microsoft.StorePurchaseApp" + "Microsoft.WindowsAlarms" + "Microsoft.WindowsCamera" + "microsoft.windowscommunicationsapps" + "Microsoft.WindowsFeedbackHub" + "Microsoft.WindowsMaps" + "Microsoft.WindowsSoundRecorder" + "Microsoft.Xbox.TCUI" + "Microsoft.XboxApp" + "Microsoft.XboxGameOverlay" + "Microsoft.XboxIdentityProvider" + "Microsoft.XboxSpeechToTextOverlay" + "Microsoft.ZuneMusic" + "Microsoft.ZuneVideo" + + #Sponsored Windows 10 AppX Apps + #Add sponsored/featured apps to remove in the "*AppName*" format + "*EclipseManager*" + "*ActiproSoftwareLLC*" + "*AdobeSystemsIncorporated.AdobePhotoshopExpress*" + "*Duolingo-LearnLanguagesforFree*" + "*PandoraMediaInc*" + "*CandyCrush*" + "*Wunderlist*" + "*Flipboard*" + "*Twitter*" + "*Facebook*" + "*Spotify*" + "*Minecraft*" + "*Royal Revolt*" + + #Optional: Typically not removed but you can if you need to for some reason + #"*Microsoft.Advertising.Xaml_10.1712.5.0_x64__8wekyb3d8bbwe*" + #"*Microsoft.Advertising.Xaml_10.1712.5.0_x86__8wekyb3d8bbwe*" + #"*Microsoft.BingWeather*" + #"*Microsoft.MSPaint*" + #"*Microsoft.MicrosoftStickyNotes*" + #"*Microsoft.Windows.Photos*" + #"*Microsoft.WindowsCalculator*" + #"*Microsoft.WindowsStore*" + ) + foreach ($Bloat in $Bloatware) { + Get-AppxPackage -Name $App | Remove-AppxPackage -ErrorAction SilentlyContinue + Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $App | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue + Write-Output "Trying to remove $Bloat." + } +} + Function Remove-Keys { [CmdletBinding()] @@ -103,10 +176,10 @@ Function Protect-Privacy { Write-Output "Disabling Bing Search in Start Menu" $WebSearch = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" Set-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" BingSearchEnabled -Value 0 - If (!(Test-Path $WebSearch)) { + If (!(Test-Path $WebSearch)) { New-Item $WebSearch - } - Set-ItemProperty $WebSearch DisableWebSearch -Value 1 + } + Set-ItemProperty $WebSearch DisableWebSearch -Value 1 #Stops the Windows Feedback Experience from sending anonymous data Write-Output "Stopping the Windows Feedback Experience program" @@ -128,12 +201,12 @@ Function Protect-Privacy { If (!(Test-Path $registryOEM)) { New-Item $registryOEM } - Set-ItemProperty $registryOEM ContentDeliveryAllowed -Value 0 - Set-ItemProperty $registryOEM OemPreInstalledAppsEnabled -Value 0 - Set-ItemProperty $registryOEM PreInstalledAppsEnabled -Value 0 - Set-ItemProperty $registryOEM PreInstalledAppsEverEnabled -Value 0 - Set-ItemProperty $registryOEM SilentInstalledAppsEnabled -Value 0 - Set-ItemProperty $registryOEM SystemPaneSuggestionsEnabled -Value 0 + Set-ItemProperty $registryOEM ContentDeliveryAllowed -Value 0 + Set-ItemProperty $registryOEM OemPreInstalledAppsEnabled -Value 0 + Set-ItemProperty $registryOEM PreInstalledAppsEnabled -Value 0 + Set-ItemProperty $registryOEM PreInstalledAppsEverEnabled -Value 0 + Set-ItemProperty $registryOEM SilentInstalledAppsEnabled -Value 0 + Set-ItemProperty $registryOEM SystemPaneSuggestionsEnabled -Value 0 #Preping mixed Reality Portal for removal Write-Output "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings" @@ -148,14 +221,14 @@ Function Protect-Privacy { $WifiSense2 = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots" $WifiSense3 = "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" If (!(Test-Path $WifiSense1)) { - New-Item $WifiSense1 + New-Item $WifiSense1 } Set-ItemProperty $WifiSense1 Value -Value 0 - If (!(Test-Path $WifiSense2)) { - New-Item $WifiSense2 + If (!(Test-Path $WifiSense2)) { + New-Item $WifiSense2 } Set-ItemProperty $WifiSense2 Value -Value 0 - Set-ItemProperty $WifiSense3 AutoConnectAllowedOEM -Value 0 + Set-ItemProperty $WifiSense3 AutoConnectAllowedOEM -Value 0 #Disables live tiles Write-Output "Disabling live tiles" @@ -212,54 +285,54 @@ Function Protect-Privacy { Write-Output "Stopping and disabling WAP Push Service" #Stop and disable WAP Push Service - Stop-Service "dmwappushservice" - Set-Service "dmwappushservice" -StartupType Disabled + Stop-Service "dmwappushservice" + Set-Service "dmwappushservice" -StartupType Disabled Write-Output "Stopping and disabling Diagnostics Tracking Service" #Disabling the Diagnostics Tracking Service - Stop-Service "DiagTrack" - Set-Service "DiagTrack" -StartupType Disabled + Stop-Service "DiagTrack" + Set-Service "DiagTrack" -StartupType Disabled } Function DisableCortana { - Write-Host "Disabling Cortana" + Write-Host "Disabling Cortana" $Cortana1 = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings" $Cortana2 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization" $Cortana3 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" - If (!(Test-Path $Cortana1)) { - New-Item $Cortana1 - } - Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 0 - If (!(Test-Path $Cortana2)) { - New-Item $Cortana2 - } - Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 1 - Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 1 - If (!(Test-Path $Cortana3)) { - New-Item $Cortana3 - } + If (!(Test-Path $Cortana1)) { + New-Item $Cortana1 + } + Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 0 + If (!(Test-Path $Cortana2)) { + New-Item $Cortana2 + } + Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 1 + Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 1 + If (!(Test-Path $Cortana3)) { + New-Item $Cortana3 + } Set-ItemProperty $Cortana3 HarvestContacts -Value 0 } Function EnableCortana { - Write-Host "Re-enabling Cortana" + Write-Host "Re-enabling Cortana" $Cortana1 = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings" $Cortana2 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization" $Cortana3 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" - If (!(Test-Path $Cortana1)) { - New-Item $Cortana1 - } - Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 1 - If (!(Test-Path $Cortana2)) { - New-Item $Cortana2 - } - Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 0 - Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 0 - If (!(Test-Path $Cortana3)) { - New-Item $Cortana3 - } - Set-ItemProperty $Cortana3 HarvestContacts -Value 1 + If (!(Test-Path $Cortana1)) { + New-Item $Cortana1 + } + Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 1 + If (!(Test-Path $Cortana2)) { + New-Item $Cortana2 + } + Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 0 + Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 0 + If (!(Test-Path $Cortana3)) { + New-Item $Cortana3 + } + Set-ItemProperty $Cortana3 HarvestContacts -Value 1 } Function Stop-EdgePDF { @@ -386,13 +459,13 @@ Function Revert-Changes { Write-Output "Re-enabling and starting WAP Push Service" #Enable and start WAP Push Service - Set-Service "dmwappushservice" -StartupType Automatic + Set-Service "dmwappushservice" -StartupType Automatic Start-Service "dmwappushservice" Write-Output "Re-enabling and starting the Diagnostics Tracking Service" #Enabling the Diagnostics Tracking Service - Set-Service "DiagTrack" -StartupType Automatic - Start-Service "DiagTrack" + Set-Service "DiagTrack" -StartupType Automatic + Start-Service "DiagTrack" } Function Enable-EdgePDF { @@ -451,24 +524,24 @@ Function UninstallOneDrive { $onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe" $ExplorerReg1 = "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" $ExplorerReg2 = "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" - Stop-Process -Name "OneDrive*" - Start-Sleep 2 - If (!(Test-Path $onedrive)) { - $onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe" - } - Start-Process $onedrive "/uninstall" -NoNewWindow -Wait - Start-Sleep 2 + Stop-Process -Name "OneDrive*" + Start-Sleep 2 + If (!(Test-Path $onedrive)) { + $onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe" + } + Start-Process $onedrive "/uninstall" -NoNewWindow -Wait + Start-Sleep 2 Write-Output "Stopping explorer" Start-Sleep 1 - .\taskkill.exe /F /IM explorer.exe - Start-Sleep 3 + .\taskkill.exe /F /IM explorer.exe + Start-Sleep 3 Write-Output "Removing leftover files" - Remove-Item "$env:USERPROFILE\OneDrive" -Force -Recurse - Remove-Item "$env:LOCALAPPDATA\Microsoft\OneDrive" -Force -Recurse - Remove-Item "$env:PROGRAMDATA\Microsoft OneDrive" -Force -Recurse - If (Test-Path "$env:SYSTEMDRIVE\OneDriveTemp") { - Remove-Item "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse - } + Remove-Item "$env:USERPROFILE\OneDrive" -Force -Recurse + Remove-Item "$env:LOCALAPPDATA\Microsoft\OneDrive" -Force -Recurse + Remove-Item "$env:PROGRAMDATA\Microsoft OneDrive" -Force -Recurse + If (Test-Path "$env:SYSTEMDRIVE\OneDriveTemp") { + Remove-Item "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse + } Write-Output "Removing OneDrive from windows explorer" If (!(Test-Path $ExplorerReg1)) { New-Item $ExplorerReg1 @@ -479,7 +552,7 @@ Function UninstallOneDrive { } Set-ItemProperty $ExplorerReg2 System.IsPinnedToNameSpaceTree -Value 0 Write-Output "Restarting Explorer that was shut down before." - Start explorer.exe -NoNewWindow + Start-Process explorer.exe -NoNewWindow } #GUI prompt Debloat/Revert options and GUI variables @@ -493,77 +566,116 @@ $Ask = 'The following will allow you to either Debloat Windows 10 or to revert c Select "No" to Revert changes made by this script Select "Cancel" to stop the script.' + +$EverythingorSpecific = "Would you like to remove everything that was preinstalled on your Windows Machine? Select Yes to remove everything, or select No to remove apps via a blacklist." $EdgePdf = "Do you want to stop edge from taking over as the default PDF viewer?" $EdgePdf2 = "Do you want to revert changes that disabled Edge as the default PDF viewer?" $Reboot = "For some of the changes to properly take effect it is recommended to reboot your machine. Would you like to restart?" $OneDriveDelete = "Do you want to uninstall One Drive?" -$Prompt1 = [Windows.MessageBox]::Show($Ask,"Debloat or Revert",$Button,$ErrorIco) +$Prompt1 = [Windows.MessageBox]::Show($Ask, "Debloat or Revert", $Button, $ErrorIco) Switch ($Prompt1) { #This will debloat Windows 10 Yes { - #Creates a "drive" to access the HKCR (HKEY_CLASSES_ROOT) - Write-Output "Creating PSDrive 'HKCR' (HKEY_CLASSES_ROOT). This will be used for the duration of the script as it is necessary for the removal and modification of specific registry keys." - New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT - Start-Sleep 1 - Write-Output "Uninstalling bloatware, please wait. The first step is to identify and remove them via a blacklist, and then to use the whitelist approach." - Start-Debloat - Write-Output "Bloatware removed." - Start-Sleep 1 - Write-Output "Removing specific registry keys." - Remove-Keys - Write-Output "Leftover bloatware registry keys removed." - Start-Sleep 1 - Write-Output "Checking to see if any Whitelisted Apps were removed, and if so re-adding them." - Start-Sleep 1 - FixWhitelistedApps - Start-Sleep 1 - Write-Output "Disabling Cortana from search, disabling feedback to Microsoft, and disabling scheduled tasks that are considered to be telemetry or unnecessary." - Protect-Privacy - Start-Sleep 1 - DisableCortana - Write-Output "Cortana disabled and removed from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled." - Start-Sleep 1 - Write-Output "Stopping and disabling Diagnostics Tracking Service" - DisableDiagTrack - Write-Output "Diagnostics Tracking Service disabled" - Start-Sleep 1 - Write-Output "Disabling WAP push service" - Start-Sleep 1 - DisableWAPPush - Write-Output "WAP push service stopped and disabled" - Start-Sleep 1; = $Debloat - $Prompt2 = [Windows.MessageBox]::Show($EdgePdf,"Edge PDF",$Button,$Warn) - Switch ($Prompt2) { + $Prompt2 = [Windows.MessageBox]::Show($EverythingorSpecific, "Everything or Specific", $Button, $Warn) + switch ($Prompt2) { + Yes { + #Creates a "drive" to access the HKCR (HKEY_CLASSES_ROOT) + Write-Output "Creating PSDrive 'HKCR' (HKEY_CLASSES_ROOT). This will be used for the duration of the script as it is necessary for the removal and modification of specific registry keys." + New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT + Start-Sleep 1 + Write-Output "Uninstalling bloatware, please wait." + DebloatAllApps + Write-Output "Bloatware removed." + Start-Sleep 1 + Write-Output "Removing specific registry keys." + Remove-Keys + Write-Output "Leftover bloatware registry keys removed." + Start-Sleep 1 + Write-Output "Checking to see if any Whitelisted Apps were removed, and if so re-adding them." + Start-Sleep 1 + FixWhitelistedApps + Start-Sleep 1 + Write-Output "Disabling Cortana from search, disabling feedback to Microsoft, and disabling scheduled tasks that are considered to be telemetry or unnecessary." + Protect-Privacy + Start-Sleep 1 + DisableCortana + Write-Output "Cortana disabled and removed from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled." + Start-Sleep 1 + Write-Output "Stopping and disabling Diagnostics Tracking Service" + DisableDiagTrack + Write-Output "Diagnostics Tracking Service disabled" + Start-Sleep 1 + Write-Output "Disabling WAP push service" + Start-Sleep 1 + DisableWAPPush + Write-Output "WAP push service stopped and disabled" + Start-Sleep 1; = $Debloat + } + No { + #Creates a "drive" to access the HKCR (HKEY_CLASSES_ROOT) + Write-Output "Creating PSDrive 'HKCR' (HKEY_CLASSES_ROOT). This will be used for the duration of the script as it is necessary for the removal and modification of specific registry keys." + New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT + Start-Sleep 1 + Write-Output "Uninstalling bloatware, please wait." + DebloatBlacklist + Write-Output "Bloatware removed." + Start-Sleep 1 + Write-Output "Removing specific registry keys." + Remove-Keys + Write-Output "Leftover bloatware registry keys removed." + Start-Sleep 1 + Write-Output "Checking to see if any Whitelisted Apps were removed, and if so re-adding them." + Start-Sleep 1 + FixWhitelistedApps + Start-Sleep 1 + Write-Output "Disabling Cortana from search, disabling feedback to Microsoft, and disabling scheduled tasks that are considered to be telemetry or unnecessary." + Protect-Privacy + Start-Sleep 1 + DisableCortana + Write-Output "Cortana disabled and removed from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled." + Start-Sleep 1 + Write-Output "Stopping and disabling Diagnostics Tracking Service" + DisableDiagTrack + Write-Output "Diagnostics Tracking Service disabled" + Start-Sleep 1 + Write-Output "Disabling WAP push service" + Start-Sleep 1 + DisableWAPPush + Write-Output "WAP push service stopped and disabled" + Start-Sleep 1; = $Debloat + } + } + + $Prompt3 = [Windows.MessageBox]::Show($EdgePdf, "Edge PDF", $Button, $Warn) + Switch ($Prompt3) { Yes { Stop-EdgePDF Write-Output "Edge will no longer take over as the default PDF viewer."; = $Yes } No { - = $No + = $No } Cancel { - Exit-PSSession } } #Prompt asking to delete OneDrive - $Prompt3 = [Windows.MessageBox]::Show($OneDriveDelete,"Delete OneDrive",$Button,$ErrorIco) - Switch ($Prompt3) { + $Prompt4 = [Windows.MessageBox]::Show($OneDriveDelete, "Delete OneDrive", $Button, $ErrorIco) + Switch ($Prompt4) { Yes { UninstallOneDrive Write-Output "OneDrive is now removed from the computer."; = $Yes } No { - = $No + = $No } Cancel { - Exit-PSSession } } #Prompt asking if you'd like to reboot your machine - $Prompt4 = [Windows.MessageBox]::Show($Reboot,"Reboot",$Button,$Warn) - Switch ($Prompt4) { + $Prompt5 = [Windows.MessageBox]::Show($Reboot, "Reboot", $Button, $Warn) + Switch ($Prompt5) { Yes { Write-Output "Unloading the HKCR drive..." Remove-PSDrive HKCR @@ -583,7 +695,6 @@ Switch ($Prompt1) { Exit; = $No } Cancel { - Exit-PSSession } } } @@ -593,21 +704,21 @@ Switch ($Prompt1) { New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT Revert-Changes; = $Revert #Prompt asking to revert edge changes as well - $Prompt5 = [Windows.MessageBox]::Show($EdgePdf2,"Revert Edge",$Button,$ErrorIco) - Switch ($Prompt5) { + $Prompt6 = [Windows.MessageBox]::Show($EdgePdf2, "Revert Edge", $Button, $ErrorIco) + Switch ($Prompt6) { Yes { Enable-EdgePDF Write-Output "Edge will no longer be disabled from being used as the default Edge PDF viewer."; = $Yes } - No { = $No + No { + = $No } Cancel { - Exit-PSSession } } #Prompt asking if you'd like to reboot your machine - $Prompt6 = [Windows.MessageBox]::Show($Reboot,"Reboot",$Button,$Warn) - Switch ($Prompt6) { + $Prompt7 = [Windows.MessageBox]::Show($Reboot, "Reboot", $Button, $Warn) + Switch ($Prompt7) { Yes { Write-Output "Unloading the HKCR drive..." Remove-PSDrive HKCR @@ -627,11 +738,9 @@ Switch ($Prompt1) { Exit; = $No } Cancel { - Exit-PSSession } } } Cancel { - Exit-PSSession } }