Windows10Debloater/Windows10Debloater.ps1

912 lines
42 KiB
PowerShell
Raw Normal View History

2019-03-18 22:56:55 +00:00
#This function finds any AppX/AppXProvisioned package and uninstalls it, except for Freshpaint, Windows Calculator, Windows Store, and Windows Photos.
#Also, to note - This does NOT remove essential system services/software/etc such as .NET framework installations, Cortana, Edge, etc.
#This will self elevate the script so with a UAC prompt since this script needs to be run as an Administrator in order to function properly.
If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) {
Write-Host "You didn't run this script as an Administrator. This script will self elevate to run as an Administrator and continue."
Start-Sleep 1
Write-Host " 3"
Start-Sleep 1
Write-Host " 2"
Start-Sleep 1
Write-Host " 1"
Start-Sleep 1
Start-Process powershell.exe -ArgumentList ("-NoProfile -ExecutionPolicy Bypass -File `"{0}`"" -f $PSCommandPath) -Verb RunAs
Exit
}
#no errors throughout
$ErrorActionPreference = 'silentlycontinue'
$DebloatFolder = "C:\Temp\Windows10Debloater"
If (Test-Path $DebloatFolder) {
Write-Output "$DebloatFolder exists. Skipping."
}
Else {
Write-Output "The folder '$DebloatFolder' doesn't exist. This folder will be used for storing logs created after the script runs. Creating now."
Start-Sleep 1
New-Item -Path "$DebloatFolder" -ItemType Directory
Write-Output "The folder $DebloatFolder was successfully created."
}
Start-Transcript -OutputDirectory "$DebloatFolder"
Add-Type -AssemblyName PresentationCore, PresentationFramework
Function DebloatAll {
#Removes AppxPackages
#Credit to /u/GavinEke for a modified version of my whitelist code
$WhitelistedApps = 'Microsoft.ScreenSketch|Microsoft.Paint3D|Microsoft.WindowsCalculator|Microsoft.WindowsStore|Microsoft.Windows.Photos|CanonicalGroupLimited.UbuntuonWindows|`
Microsoft.XboxGameCallableUI|Microsoft.XboxGamingOverlay|Microsoft.Xbox.TCUI|Microsoft.XboxGamingOverlay|Microsoft.XboxIdentityProvider|Microsoft.MicrosoftStickyNotes|Microsoft.MSPaint|Microsoft.WindowsCamera|.NET|Framework|`
Microsoft.HEIFImageExtension|Microsoft.ScreenSketch|Microsoft.StorePurchaseApp|Microsoft.VP9VideoExtensions|Microsoft.WebMediaExtensions|Microsoft.WebpImageExtension|Microsoft.DesktopAppInstaller|WindSynthBerry|MIDIBerry|Slack'
#NonRemovable Apps that where getting attempted and the system would reject the uninstall, speeds up debloat and prevents 'initalizing' overlay when removing apps
$NonRemovable = '1527c705-839a-4832-9118-54d4Bd6a0c89|c5e2524a-ea46-4f67-841f-6a9465d9d515|E2A4F912-2574-4A75-9BB0-0D023378592B|F46D4000-FD22-4DB4-AC8E-4E1DDDE828FE|InputApp|Microsoft.AAD.BrokerPlugin|Microsoft.AccountsControl|`
Microsoft.BioEnrollment|Microsoft.CredDialogHost|Microsoft.ECApp|Microsoft.LockApp|Microsoft.MicrosoftEdgeDevToolsClient|Microsoft.MicrosoftEdge|Microsoft.PPIProjection|Microsoft.Win32WebViewHost|Microsoft.Windows.Apprep.ChxApp|`
Microsoft.Windows.AssignedAccessLockApp|Microsoft.Windows.CapturePicker|Microsoft.Windows.CloudExperienceHost|Microsoft.Windows.ContentDeliveryManager|Microsoft.Windows.Cortana|Microsoft.Windows.NarratorQuickStart|`
Microsoft.Windows.ParentalControls|Microsoft.Windows.PeopleExperienceHost|Microsoft.Windows.PinningConfirmationDialog|Microsoft.Windows.SecHealthUI|Microsoft.Windows.SecureAssessmentBrowser|Microsoft.Windows.ShellExperienceHost|`
Microsoft.Windows.XGpuEjectDialog|Microsoft.XboxGameCallableUI|Windows.CBSPreview|windows.immersivecontrolpanel|Windows.PrintDialog|Microsoft.VCLibs.140.00|Microsoft.Services.Store.Engagement|Microsoft.UI.Xaml.2.0'
Get-AppxPackage -AllUsers | Where {$_.Name -NotMatch $WhitelistedApps -and $_.Name -NotMatch $NonRemovable} | Remove-AppxPackage
Get-AppxPackage | Where {$_.Name -NotMatch $WhitelistedApps -and $_.Name -NotMatch $NonRemovable} | Remove-AppxPackage
Get-AppxProvisionedPackage -Online | Where {$_.Name -NotMatch $WhitelistedApps -and $_.Name -NotMatch $NonRemovable} | Remove-AppxProvisionedPackage -Online
}
Function DebloatBlacklist {
$Bloatware = @(
#Unnecessary Windows 10 AppX Apps
"Microsoft.BingNews"
"Microsoft.GetHelp"
"Microsoft.Getstarted"
"Microsoft.Messaging"
"Microsoft.Microsoft3DViewer"
"Microsoft.MicrosoftOfficeHub"
"Microsoft.MicrosoftSolitaireCollection"
"Microsoft.NetworkSpeedTest"
"Microsoft.News"
"Microsoft.Office.Lens"
"Microsoft.Office.OneNote"
"Microsoft.Office.Sway"
"Microsoft.OneConnect"
"Microsoft.People"
"Microsoft.Print3D"
"Microsoft.RemoteDesktop"
"Microsoft.SkypeApp"
"Microsoft.StorePurchaseApp"
"Microsoft.Office.Todo.List"
"Microsoft.Whiteboard"
"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*"
"*Sway*"
"*Speed Test*"
"*Dolby*"
#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 $Bloat| Remove-AppxPackage
Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $Bloat | Remove-AppxProvisionedPackage -Online
Write-Output "Trying to remove $Bloat."
}
}
Function Remove-Keys {
#These are the registry keys that it will delete.
$Keys = @(
#Remove Background Tasks
"HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
"HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
"HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
"HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
"HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
"HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
#Windows File
"HKCR:\Extensions\ContractId\Windows.File\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
#Registry keys to delete if they aren't uninstalled by RemoveAppXPackage/RemoveAppXProvisionedPackage
"HKCR:\Extensions\ContractId\Windows.Launch\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
"HKCR:\Extensions\ContractId\Windows.Launch\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
"HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
"HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
"HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
#Scheduled Tasks to delete
"HKCR:\Extensions\ContractId\Windows.PreInstalledConfigTask\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
#Windows Protocol Keys
"HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
"HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
"HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
"HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
#Windows Share Target
"HKCR:\Extensions\ContractId\Windows.ShareTarget\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
)
#This writes the output of each key it is removing and also removes the keys listed above.
ForEach ($Key in $Keys) {
Write-Output "Removing $Key from registry"
Remove-Item $Key -Recurse
}
}
Function Protect-Privacy {
#Disables Windows Feedback Experience
Write-Output "Disabling Windows Feedback Experience program"
$Advertising = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"
If (Test-Path $Advertising) {
Set-ItemProperty $Advertising Enabled -Value 0
}
#Stops Cortana from being used as part of your Windows Search Function
Write-Output "Stopping Cortana from being used as part of your Windows Search Function"
$Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
If (Test-Path $Search) {
Set-ItemProperty $Search AllowCortana -Value 0
}
#Disables Web Search in Start Menu
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)) {
New-Item $WebSearch
}
Set-ItemProperty $WebSearch DisableWebSearch -Value 1
#Stops the Windows Feedback Experience from sending anonymous data
Write-Output "Stopping the Windows Feedback Experience program"
$Period = "HKCU:\Software\Microsoft\Siuf\Rules"
If (!(Test-Path $Period)) {
New-Item $Period
}
Set-ItemProperty $Period PeriodInNanoSeconds -Value 0
#Prevents bloatware applications from returning and removes Start Menu suggestions
Write-Output "Adding Registry key to prevent bloatware apps from returning"
$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
$registryOEM = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
If (!(Test-Path $registryPath)) {
New-Item $registryPath
}
Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 1
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
#Preping mixed Reality Portal for removal
Write-Output "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings"
$Holo = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic"
If (Test-Path $Holo) {
Set-ItemProperty $Holo FirstRunSucceeded -Value 0
}
#Disables Wi-fi Sense
Write-Output "Disabling Wi-Fi Sense"
$WifiSense1 = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting"
$WifiSense2 = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots"
$WifiSense3 = "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config"
If (!(Test-Path $WifiSense1)) {
New-Item $WifiSense1
}
Set-ItemProperty $WifiSense1 Value -Value 0
If (!(Test-Path $WifiSense2)) {
New-Item $WifiSense2
}
Set-ItemProperty $WifiSense2 Value -Value 0
Set-ItemProperty $WifiSense3 AutoConnectAllowedOEM -Value 0
#Disables live tiles
Write-Output "Disabling live tiles"
$Live = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications"
If (!(Test-Path $Live)) {
New-Item $Live
}
Set-ItemProperty $Live NoTileApplicationNotification -Value 1
#Turns off Data Collection via the AllowTelemtry key by changing it to 0
Write-Output "Turning off Data Collection"
$DataCollection1 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
$DataCollection2 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection"
$DataCollection3 = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
If (Test-Path $DataCollection1) {
Set-ItemProperty $DataCollection1 AllowTelemetry -Value 0
}
If (Test-Path $DataCollection2) {
Set-ItemProperty $DataCollection2 AllowTelemetry -Value 0
}
If (Test-Path $DataCollection3) {
Set-ItemProperty $DataCollection3 AllowTelemetry -Value 0
}
#Disabling Location Tracking
Write-Output "Disabling Location Tracking"
$SensorState = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}"
$LocationConfig = "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration"
If (!(Test-Path $SensorState)) {
New-Item $SensorState
}
Set-ItemProperty $SensorState SensorPermissionState -Value 0
If (!(Test-Path $LocationConfig)) {
New-Item $LocationConfig
}
Set-ItemProperty $LocationConfig Status -Value 0
#Disables People icon on Taskbar
Write-Output "Disabling People icon on Taskbar"
$People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
If (Test-Path $People) {
Set-ItemProperty $People -Name PeopleBand -Value 0
}
#Disables scheduled tasks that are considered unnecessary
Write-Output "Disabling scheduled tasks"
Get-ScheduledTask XblGameSaveTaskLogon | Disable-ScheduledTask
Get-ScheduledTask XblGameSaveTask | Disable-ScheduledTask
Get-ScheduledTask Consolidator | Disable-ScheduledTask
Get-ScheduledTask UsbCeip | Disable-ScheduledTask
Get-ScheduledTask DmClient | Disable-ScheduledTask
Get-ScheduledTask DmClientOnScenarioDownload | Disable-ScheduledTask
Write-Output "Stopping and disabling Diagnostics Tracking Service"
#Disabling the Diagnostics Tracking Service
Stop-Service "DiagTrack"
Set-Service "DiagTrack" -StartupType Disabled
2019-03-18 22:58:47 +00:00
Write-Output "Removing CloudStore from registry if it exists"
$CloudStore = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\CloudStore'
2019-03-18 22:58:47 +00:00
If (Test-Path $CloudStore) {
Stop-Process Explorer.exe -Force
Remove-Item $CloudStore
Start-Process Explorer.exe -Wait
}
2019-03-18 22:56:55 +00:00
}
Function DisableCortana {
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
}
Set-ItemProperty $Cortana3 HarvestContacts -Value 0
}
Function EnableCortana {
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
}
Function Stop-EdgePDF {
#Stops edge from taking over as the default .PDF viewer
Write-Output "Stopping Edge from taking over as the default .PDF viewer"
$NoPDF = "HKCR:\.pdf"
$NoProgids = "HKCR:\.pdf\OpenWithProgids"
$NoWithList = "HKCR:\.pdf\OpenWithList"
If (!(Get-ItemProperty $NoPDF NoOpenWith)) {
New-ItemProperty $NoPDF NoOpenWith
}
If (!(Get-ItemProperty $NoPDF NoStaticDefaultVerb)) {
New-ItemProperty $NoPDF NoStaticDefaultVerb
}
If (!(Get-ItemProperty $NoProgids NoOpenWith)) {
New-ItemProperty $NoProgids NoOpenWith
}
If (!(Get-ItemProperty $NoProgids NoStaticDefaultVerb)) {
New-ItemProperty $NoProgids NoStaticDefaultVerb
}
If (!(Get-ItemProperty $NoWithList NoOpenWith)) {
New-ItemProperty $NoWithList NoOpenWith
}
If (!(Get-ItemProperty $NoWithList NoStaticDefaultVerb)) {
New-ItemProperty $NoWithList NoStaticDefaultVerb
}
#Appends an underscore '_' to the Registry key for Edge
$Edge = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_"
If (Test-Path $Edge) {
Set-Item $Edge AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_
}
}
Function Revert-Changes {
#This function will revert the changes you made when running the Start-Debloat function.
#This line reinstalls all of the bloatware that was removed
Get-AppxPackage -AllUsers | ForEach {Add-AppxPackage -Verbose -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
#Tells Windows to enable your advertising information.
Write-Output "Re-enabling key to show advertisement information"
$Advertising = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"
If (Test-Path $Advertising) {
Set-ItemProperty $Advertising Enabled -Value 1
}
#Enables Cortana to be used as part of your Windows Search Function
Write-Output "Re-enabling Cortana to be used in your Windows Search"
$Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
If (Test-Path $Search) {
Set-ItemProperty $Search AllowCortana -Value 1
}
#Re-enables the Windows Feedback Experience for sending anonymous data
Write-Output "Re-enabling Windows Feedback Experience"
$Period = "HKCU:\Software\Microsoft\Siuf\Rules"
If (!(Test-Path $Period)) {
New-Item $Period
}
Set-ItemProperty $Period PeriodInNanoSeconds -Value 1
#Enables bloatware applications
Write-Output "Adding Registry key to allow bloatware apps to return"
$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
If (!(Test-Path $registryPath)) {
New-Item $registryPath
}
Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 0
#Changes Mixed Reality Portal Key 'FirstRunSucceeded' to 1
Write-Output "Setting Mixed Reality Portal value to 1"
$Holo = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic"
If (Test-Path $Holo) {
Set-ItemProperty $Holo FirstRunSucceeded -Value 1
}
#Re-enables live tiles
Write-Output "Enabling live tiles"
$Live = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications"
If (!(Test-Path $Live)) {
New-Item $Live
}
Set-ItemProperty $Live NoTileApplicationNotification -Value 0
#Re-enables data collection
Write-Output "Re-enabling data collection"
$DataCollection = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
If (!(Test-Path $DataCollection)) {
New-Item $DataCollection
}
Set-ItemProperty $DataCollection AllowTelemetry -Value 1
#Re-enables People Icon on Taskbar
Write-Output "Enabling People icon on Taskbar"
$People = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People"
If (!(Test-Path $People)) {
New-Item $People
}
Set-ItemProperty $People PeopleBand -Value 1
#Re-enables suggestions on start menu
Write-Output "Enabling suggestions on the Start Menu"
$Suggestions = "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
If (!(Test-Path $Suggestions)) {
New-Item $Suggestions
}
Set-ItemProperty $Suggestions SystemPaneSuggestionsEnabled -Value 1
#Re-enables scheduled tasks that were disabled when running the Debloat switch
Write-Output "Enabling scheduled tasks that were disabled"
Get-ScheduledTask XblGameSaveTaskLogon | Enable-ScheduledTask
Get-ScheduledTask XblGameSaveTask | Enable-ScheduledTask
Get-ScheduledTask Consolidator | Enable-ScheduledTask
Get-ScheduledTask UsbCeip | Enable-ScheduledTask
Get-ScheduledTask DmClient | Enable-ScheduledTask
Get-ScheduledTask DmClientOnScenarioDownload | Enable-ScheduledTask
Write-Output "Re-enabling and starting WAP Push Service"
#Enable and start WAP Push Service
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"
Write-Output "Restoring 3D Objects in the 'My Computer' submenu in explorer"
#Restoring 3D Objects in the 'My Computer' submenu in explorer
Restore3dObjects
}
Function CheckDMWService {
2019-03-18 22:58:47 +00:00
Param([switch]$Debloat)
2019-03-18 22:56:55 +00:00
2019-03-18 22:58:47 +00:00
If (Get-Service -Name dmwappushservice | Where-Object {$_.StartType -eq "Disabled"}) {
Set-Service -Name dmwappushservice -StartupType Automatic
}
2019-03-18 22:56:55 +00:00
2019-03-18 22:58:47 +00:00
If (Get-Service -Name dmwappushservice | Where-Object {$_.Status -eq "Stopped"}) {
Start-Service -Name dmwappushservice
}
}
2019-03-18 22:56:55 +00:00
Function Enable-EdgePDF {
Write-Output "Setting Edge back to default"
$NoPDF = "HKCR:\.pdf"
$NoProgids = "HKCR:\.pdf\OpenWithProgids"
$NoWithList = "HKCR:\.pdf\OpenWithList"
#Sets edge back to default
If (Get-ItemProperty $NoPDF NoOpenWith) {
Remove-ItemProperty $NoPDF NoOpenWith
}
If (Get-ItemProperty $NoPDF NoStaticDefaultVerb) {
Remove-ItemProperty $NoPDF NoStaticDefaultVerb
}
If (Get-ItemProperty $NoProgids NoOpenWith) {
Remove-ItemProperty $NoProgids NoOpenWith
}
If (Get-ItemProperty $NoProgids NoStaticDefaultVerb) {
Remove-ItemProperty $NoProgids NoStaticDefaultVerb
}
If (Get-ItemProperty $NoWithList NoOpenWith) {
Remove-ItemProperty $NoWithList NoOpenWith
}
If (Get-ItemProperty $NoWithList NoStaticDefaultVerb) {
Remove-ItemProperty $NoWithList NoStaticDefaultVerb
}
#Removes an underscore '_' from the Registry key for Edge
$Edge2 = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_"
If (Test-Path $Edge2) {
Set-Item $Edge2 AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723
}
}
Function FixWhitelistedApps {
If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.Windows.Photos)) {
#Credit to abulgatz for these 4 lines of code
Get-AppxPackage -allusers Microsoft.Paint3D | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
Get-AppxPackage -allusers Microsoft.WindowsCalculator | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
Get-AppxPackage -allusers Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
Get-AppxPackage -allusers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
}
}
Function UninstallOneDrive {
Write-Host "Checking for pre-existing files and folders located in the OneDrive folders..."
Start-Sleep 1
If (Test-Path "$env:USERPROFILE\OneDrive\*") {
2019-03-18 22:58:47 +00:00
Write-Host "Files found within the OneDrive folder! Checking to see if a folder named OneDriveBackupFiles exists."
Start-Sleep 1
2019-03-18 22:56:55 +00:00
2019-03-18 22:58:47 +00:00
If (Test-Path "$env:USERPROFILE\Desktop\OneDriveBackupFiles") {
Write-Host "A folder named OneDriveBackupFiles already exists on your desktop. All files from your OneDrive location will be moved to that folder."
2019-03-18 22:56:55 +00:00
}
2019-03-18 22:58:47 +00:00
else {
If (!(Test-Path "$env:USERPROFILE\Desktop\OneDriveBackupFiles")) {
Write-Host "A folder named OneDriveBackupFiles will be created and will be located on your desktop. All files from your OneDrive location will be located in that folder."
New-item -Path "$env:USERPROFILE\Desktop" -Name "OneDriveBackupFiles"-ItemType Directory -Force
Write-Host "Successfully created the folder 'OneDriveBackupFiles' on your desktop."
2019-03-18 22:56:55 +00:00
}
2019-03-18 22:58:47 +00:00
}
Start-Sleep 1
Move-Item -Path "$env:USERPROFILE\OneDrive\*" -Destination "$env:USERPROFILE\Desktop\OneDriveBackupFiles" -Force
Write-Host "Successfully moved all files/folders from your OneDrive folder to the folder 'OneDriveBackupFiles' on your desktop."
Start-Sleep 1
Write-Host "Proceeding with the removal of OneDrive."
Start-Sleep 1
}
Else {
Write-Host "Either the OneDrive folder does not exist or there are no files to be found in the folder. Proceeding with removal of OneDrive."
Start-Sleep 1
Write-Host "Enabling the Group Policy 'Prevent the usage of OneDrive for File Storage'."
$OneDriveKey = 'HKLM:Software\Policies\Microsoft\Windows\OneDrive'
If (!(Test-Path $OneDriveKey)) {
Mkdir $OneDriveKey
2019-03-18 22:56:55 +00:00
Set-ItemProperty $OneDriveKey -Name OneDrive -Value DisableFileSyncNGSC
}
2019-03-18 22:58:47 +00:00
Set-ItemProperty $OneDriveKey -Name OneDrive -Value DisableFileSyncNGSC
}
2019-03-18 22:56:55 +00:00
2019-03-18 22:58:47 +00:00
Write-Host "Uninstalling OneDrive. Please wait..."
2019-03-18 22:56:55 +00:00
New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
$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"
2019-03-18 22:58:47 +00:00
New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
$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
Write-Output "Stopping explorer"
Start-Sleep 1
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
}
Write-Output "Removing OneDrive from windows explorer"
If (!(Test-Path $ExplorerReg1)) {
New-Item $ExplorerReg1
}
Set-ItemProperty $ExplorerReg1 System.IsPinnedToNameSpaceTree -Value 0
If (!(Test-Path $ExplorerReg2)) {
New-Item $ExplorerReg2
}
Set-ItemProperty $ExplorerReg2 System.IsPinnedToNameSpaceTree -Value 0
Write-Output "Restarting Explorer that was shut down before."
Start-Process explorer.exe -NoNewWindow
2019-03-18 22:56:55 +00:00
2019-03-18 22:58:47 +00:00
Write-Host "Enabling the Group Policy 'Prevent the usage of OneDrive for File Storage'."
2019-03-18 22:56:55 +00:00
$OneDriveKey = 'HKLM:Software\Policies\Microsoft\Windows\OneDrive'
If (!(Test-Path $OneDriveKey)) {
Mkdir $OneDriveKey
}
Start-Process $onedrive "/uninstall" -NoNewWindow -Wait
Start-Sleep 2
Write-Host "Stopping explorer"
Start-Sleep 1
taskkill.exe /F /IM explorer.exe
Start-Sleep 3
Write-Host "Removing leftover files"
If (Test-Path "$env:USERPROFILE\OneDrive") {
Remove-Item "$env:USERPROFILE\OneDrive" -Force -Recurse
}
If (Test-Path "$env:LOCALAPPDATA\Microsoft\OneDrive") {
Remove-Item "$env:LOCALAPPDATA\Microsoft\OneDrive" -Force -Recurse
}
If (Test-Path "$env:PROGRAMDATA\Microsoft OneDrive") {
Remove-Item "$env:PROGRAMDATA\Microsoft OneDrive" -Force -Recurse
}
If (Test-Path "$env:SYSTEMDRIVE\OneDriveTemp") {
Remove-Item "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse
}
Write-Host "Removing OneDrive from windows explorer"
If (!(Test-Path $ExplorerReg1)) {
New-Item $ExplorerReg1
}
Set-ItemProperty $ExplorerReg1 System.IsPinnedToNameSpaceTree -Value 0
If (!(Test-Path $ExplorerReg2)) {
New-Item $ExplorerReg2
}
Set-ItemProperty $ExplorerReg2 System.IsPinnedToNameSpaceTree -Value 0
Write-Host "Restarting Explorer that was shut down before."
Start-Process explorer.exe -NoNewWindow
Write-Host "OneDrive has been successfully uninstalled!"
2019-03-18 22:58:47 +00:00
}
2019-03-18 22:56:55 +00:00
}
Function UnpinStart {
2019-03-18 22:58:47 +00:00
#https://superuser.com/questions/1068382/how-to-remove-all-the-tiles-in-the-windows-10-start-menu
#Unpins all tiles from the Start Menu
2019-03-18 22:56:55 +00:00
Write-Host "Unpinning all tiles from the start menu"
(New-Object -Com Shell.Application).
NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').
Items() |
2019-03-18 22:58:47 +00:00
% { $_.Verbs() } |
? {$_.Name -match 'Un.*pin from Start'} |
% {$_.DoIt()}
2019-03-18 22:56:55 +00:00
}
Function Remove3dObjects {
2019-03-18 22:58:47 +00:00
#Removes 3D Objects from the 'My Computer' submenu in explorer
2019-03-18 22:56:55 +00:00
Write-Host "Removing 3D Objects from explorer 'My Computer' submenu"
$Objects32 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
$Objects64 = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
If (Test-Path $Objects32) {
Remove-Item $Objects32 -Recurse
}
If (Test-Path $Objects64) {
Remove-Item $Objects64 -Recurse
}
}
Function Restore3dObjects {
2019-03-18 22:58:47 +00:00
#Restores 3D Objects from the 'My Computer' submenu in explorer
2019-03-18 22:56:55 +00:00
Write-Host "Restoring 3D Objects from explorer 'My Computer' submenu"
$Objects32 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
$Objects64 = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
If (!(Test-Path $Objects32)) {
New-Item $Objects32
}
If (!(Test-Path $Objects64)) {
New-Item $Objects64
}
}
#Interactive prompt Debloat/Revert options
$Button = [Windows.MessageBoxButton]::YesNoCancel
$ErrorIco = [Windows.MessageBoxImage]::Error
$Warn = [Windows.MessageBoxImage]::Warning
$Ask = 'The following will allow you to either Debloat Windows 10 or to revert changes made after Debloating Windows 10.
Select "Yes" to Debloat Windows 10
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?"
$Unpin = "Do you want to unpin all items from the Start menu?"
$InstallNET = "Do you want to install .NET 3.5?"
$Prompt1 = [Windows.MessageBox]::Show($Ask, "Debloat or Revert", $Button, $ErrorIco)
Switch ($Prompt1) {
#This will debloat Windows 10
Yes {
#Everything is specific prompt
$Prompt2 = [Windows.MessageBox]::Show($EverythingorSpecific, "Everything or Specific", $Button, $Warn)
switch ($Prompt2) {
Yes {
#Creates a "drive" to access the HKCR (HKEY_CLASSES_ROOT)
Write-Host "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-Host "Uninstalling bloatware, please wait."
DebloatAll
Write-Host "Bloatware removed."
Start-Sleep 1
Write-Host "Removing specific registry keys."
Remove-Keys
Write-Host "Leftover bloatware registry keys removed."
Start-Sleep 1
Write-Host "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
Start-Sleep 1
FixWhitelistedApps
Start-Sleep 1
Write-Host "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-Host "Cortana disabled and removed from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled."
Start-Sleep 1
Write-Host "Stopping and disabling Diagnostics Tracking Service"
DisableDiagTrack
Write-Host "Diagnostics Tracking Service disabled"
Start-Sleep 1
Write-Host "Disabling WAP push service"
DisableWAPPush
Start-Sleep 1
Write-Host "Re-enabling DMWAppushservice if it was disabled"
CheckDMWService
Start-Sleep 1
Write-Host "Removing 3D Objects from the 'My Computer' submenu in explorer"
Remove3dObjects
Start-Sleep 1
}
No {
#Creates a "drive" to access the HKCR (HKEY_CLASSES_ROOT)
Write-Host "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-Host "Uninstalling bloatware, please wait."
DebloatBlacklist
Write-Host "Bloatware removed."
Start-Sleep 1
Write-Host "Removing specific registry keys."
Remove-Keys
Write-Host "Leftover bloatware registry keys removed."
Start-Sleep 1
Write-Host "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
Start-Sleep 1
FixWhitelistedApps
Start-Sleep 1
Write-Host "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-Host "Cortana disabled and removed from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled."
Start-Sleep 1
Write-Host "Stopping and disabling Diagnostics Tracking Service"
DisableDiagTrack
Write-Host "Diagnostics Tracking Service disabled"
Start-Sleep 1
Write-Host "Disabling WAP push service"
Start-Sleep 1
DisableWAPPush
Write-Host "Re-enabling DMWAppushservice if it was disabled"
CheckDMWService
Start-Sleep 1
}
}
#Disabling EdgePDF prompt
$Prompt3 = [Windows.MessageBox]::Show($EdgePdf, "Edge PDF", $Button, $Warn)
Switch ($Prompt3) {
Yes {
Stop-EdgePDF
Write-Host "Edge will no longer take over as the default PDF viewer."
}
No {
Write-Host "You chose not to stop Edge from taking over as the default PDF viewer."
}
}
#Prompt asking to delete OneDrive
$Prompt4 = [Windows.MessageBox]::Show($OneDriveDelete, "Delete OneDrive", $Button, $ErrorIco)
Switch ($Prompt4) {
Yes {
UninstallOneDrive
Write-Host "OneDrive is now removed from the computer."
}
No {
Write-Host "You have chosen to skip removing OneDrive from your machine."
}
}
2019-03-18 22:58:47 +00:00
#Prompt asking if you'd like to unpin all start items
$Prompt5 = [Windows.MessageBox]::Show($Unpin, "Unpin", $Button, $ErrorIco)
2019-03-18 22:56:55 +00:00
Switch ($Prompt5) {
Yes {
UnpinStart
2019-03-18 22:58:47 +00:00
Write-Host "Start Apps unpined."
2019-03-18 22:56:55 +00:00
}
No {
2019-03-18 22:58:47 +00:00
Write-Host "Apps will remain pinned to the start menu."
2019-03-18 22:56:55 +00:00
}
}
#Prompt asking if you want to install .NET
$Prompt6 = [Windows.MessageBox]::Show($InstallNET, "Install .Net", $Button, $Warn)
Switch ($Prompt6) {
Yes {
Write-Host "Initializing the installation of .NET 3.5..."
DISM /Online /Enable-Feature /FeatureName:NetFx3 /All
Write-Host ".NET 3.5 has been successfully installed!"
2019-03-18 22:58:47 +00:00
}
2019-03-18 22:56:55 +00:00
No {
Write-Host "Skipping .NET install."
}
2019-03-18 22:58:47 +00:00
}
2019-03-18 22:56:55 +00:00
#Prompt asking if you'd like to reboot your machine
$Prompt7 = [Windows.MessageBox]::Show($Reboot, "Reboot", $Button, $Warn)
Switch ($Prompt7) {
Yes {
Write-Host "Unloading the HKCR drive..."
Remove-PSDrive HKCR
Start-Sleep 1
Write-Host "Initiating reboot."
Stop-Transcript
Start-Sleep 2
Restart-Computer
}
No {
Write-Host "Unloading the HKCR drive..."
Remove-PSDrive HKCR
Start-Sleep 1
Write-Host "Script has finished. Exiting."
Stop-Transcript
Start-Sleep 2
Exit
}
}
}
}
2019-03-18 22:58:47 +00:00
No {
Write-Host "Reverting changes..."
Write-Host "Creating PSDrive 'HKCR' (HKEY_CLASSES_ROOT). This will be used for the duration of the script as it is necessary for the modification of specific registry keys."
New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
Revert-Changes
#Prompt asking to revert edge changes as well
$Prompt6 = [Windows.MessageBox]::Show($EdgePdf2, "Revert Edge", $Button, $ErrorIco)
Switch ($Prompt6) {
Yes {
Enable-EdgePDF
Write-Host "Edge will no longer be disabled from being used as the default Edge PDF viewer."
2019-03-18 22:56:55 +00:00
}
2019-03-18 22:58:47 +00:00
No {
Write-Host "You have chosen to keep the setting that disallows Edge to be the default PDF viewer."
2019-03-18 22:56:55 +00:00
}
}
2019-03-18 22:58:47 +00:00
#Prompt asking if you'd like to reboot your machine
$Prompt7 = [Windows.MessageBox]::Show($Reboot, "Reboot", $Button, $Warn)
Switch ($Prompt7) {
Yes {
Write-Host "Unloading the HKCR drive..."
Remove-PSDrive HKCR
Start-Sleep 1
Write-Host "Initiating reboot."
Stop-Transcript
Start-Sleep 2
Restart-Computer
}
No {
Write-Host "Unloading the HKCR drive..."
Remove-PSDrive HKCR
Start-Sleep 1
Write-Host "Script has finished. Exiting."
Stop-Transcript
Start-Sleep 2
Exit
}
}
}