mirror of
https://github.com/Sycnex/Windows10Debloater.git
synced 2024-11-24 11:45:29 +00:00
12fe2f5aef
I added a $SysPrep switch parameter and function on lines 7 - 17. This will run the following command: get-appxpackage | remove-appxpackage. This is required in order to be used successfully with SysPrep. I also added a $StopEdgePDF parameter, for those who do not wish to stop Edge from being used as the default PDF viewer, or for those who worry about unintended consequences (not being able to potentially choose Edge without removing the specified registry keys). You can now run the script with the switch parameter -SysPrep, along with -Debloat, and -StopEdgePDF.
236 lines
12 KiB
PowerShell
236 lines
12 KiB
PowerShell
#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 is the switch parameter for running this script as a 'silent' script, for use in MDT images or any type of mass deployment without user interaction.
|
|
param([switch]$Debloat)
|
|
|
|
param([switch]$SysPrep)
|
|
|
|
param([switch]$StopEdgePDF)
|
|
|
|
#This will run get-appxpackage | remove-appxpackage which is required for sysprep to provision the apps.
|
|
Function Begin-SysPrep {
|
|
|
|
param([switch]$SysPrep)
|
|
|
|
get-appxpackage | remove-appxpackage
|
|
|
|
}
|
|
|
|
#Creates a PSDrive to be able to access the 'HKCR' tree
|
|
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
|
|
Function Start-Debloat {
|
|
|
|
param([switch]$Debloat)
|
|
|
|
#Removes AppxPackages
|
|
Get-AppxPackage -AllUsers |
|
|
Where-Object {$_.name -notlike "*Microsoft.Paint3D"} |
|
|
Where-Object {$_.name -notlike "*Microsoft.WindowsCalculator*"} |
|
|
Where-Object {$_.packagename -notlike "*Microsoft.WindowsStore*"} |
|
|
Where-Object {$_.packagename -notlike "*Microsoft.Windows.Photos*"} |
|
|
Remove-AppxPackage -ErrorAction SilentlyContinue
|
|
|
|
#Removes AppxProvisionedPackages
|
|
Get-AppxProvisionedPackage -online |
|
|
Where-Object {$_.packagename -notlike "*Microsoft.Paint3D*"} |
|
|
Where-Object {$_.packagename -notlike "*Microsoft.WindowsCalculator*"} |
|
|
Where-Object {$_.packagename -notlike "*Microsoft.WindowsStore*"} |
|
|
Where-Object {$_.packagename -notlike "*Microsoft.Windows.Photos*"} |
|
|
Remove-AppxProvisionedPackage -online -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
Function Remove-Keys {
|
|
|
|
Param([switch]$Debloat)
|
|
|
|
#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 -ErrorAction SilentlyContinue
|
|
}
|
|
}
|
|
|
|
Function Protect-Privacy {
|
|
|
|
Param([switch]$Debloat)
|
|
|
|
#Creates a PSDrive to be able to access the 'HKCR' tree
|
|
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
|
|
|
|
#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 -Name Enabled -Value 0 -Verbose
|
|
}
|
|
|
|
#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 -Name AllowCortana -Value 0 -Verbose
|
|
}
|
|
|
|
#Stops the Windows Feedback Experience from sending anonymous data
|
|
Write-Output "Stopping the Windows Feedback Experience program"
|
|
$Period1 = 'HKCU:\Software\Microsoft\Siuf'
|
|
$Period2 = 'HKCU:\Software\Microsoft\Siuf\Rules'
|
|
$Period3 = 'HKCU:\Software\Microsoft\Siuf\Rules\PeriodInNanoSeconds'
|
|
If (!(Test-Path $Period3)) {
|
|
mkdir $Period1 -ErrorAction SilentlyContinue
|
|
mkdir $Period2 -ErrorAction SilentlyContinue
|
|
mkdir $Period3 -ErrorAction SilentlyContinue
|
|
New-ItemProperty $Period3 -Name PeriodInNanoSeconds -Value 0 -Verbose -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
Write-Output "Adding Registry key to prevent bloatware apps from returning"
|
|
#Prevents bloatware applications from returning
|
|
$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
|
|
If (!(Test-Path $registryPath)) {
|
|
Mkdir $registryPath -ErrorAction SilentlyContinue
|
|
New-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 1 -Verbose -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
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 -Name FirstRunSucceeded -Value 0 -Verbose
|
|
}
|
|
|
|
#Disables live tiles
|
|
Write-Output "Disabling live tiles"
|
|
$Live = 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications'
|
|
If (!(Test-Path $Live)) {
|
|
mkdir $Live -ErrorAction SilentlyContinue
|
|
New-ItemProperty $Live -Name NoTileApplicationNotification -Value 1 -Verbose
|
|
}
|
|
|
|
#Turns off Data Collection via the AllowTelemtry key by changing it to 0
|
|
Write-Output "Turning off Data Collection"
|
|
$DataCollection = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection'
|
|
If (Test-Path $DataCollection) {
|
|
Set-ItemProperty $DataCollection -Name AllowTelemetry -Value 0 -Verbose
|
|
}
|
|
|
|
#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)) {
|
|
mkdir $People -ErrorAction SilentlyContinue
|
|
New-ItemProperty $People -Name PeopleBand -Value 0 -Verbose
|
|
}
|
|
|
|
#Disables suggestions on start menu
|
|
Write-Output "Disabling suggestions on the Start Menu"
|
|
$Suggestions = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager'
|
|
If (Test-Path $Suggestions) {
|
|
Set-ItemProperty $Suggestions -Name SystemPaneSuggestionsEnabled -Value 0 -Verbose
|
|
}
|
|
|
|
#Loads the registry keys/values below into the NTUSER.DAT file which prevents the apps from redownloading. Credit to a60wattfish
|
|
reg load HKU\Default_User C:\Users\Default\NTUSER.DAT
|
|
Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SystemPaneSuggestionsEnabled -Value 0
|
|
Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name PreInstalledAppsEnabled -Value 0
|
|
Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name OemPreInstalledAppsEnabled -Value 0
|
|
reg unload HKU\Default_User
|
|
|
|
#Disables scheduled tasks that are considered unnecessary
|
|
Write-Output "Disabling scheduled tasks"
|
|
Get-ScheduledTask -TaskName XblGameSaveTaskLogon | Disable-ScheduledTask
|
|
Get-ScheduledTask -TaskName XblGameSaveTask | Disable-ScheduledTask
|
|
Get-ScheduledTask -TaskName Consolidator | Disable-ScheduledTask
|
|
Get-ScheduledTask -TaskName UsbCeip | Disable-ScheduledTask
|
|
Get-ScheduledTask -TaskName DmClient | Disable-ScheduledTask
|
|
Get-ScheduledTask -TaskName DmClientOnScenarioDownload | Disable-ScheduledTask
|
|
}
|
|
|
|
Function Stop-EdgePDF {
|
|
|
|
param([switch]$StopEdgePDF)
|
|
|
|
#Stops edge from taking over as the default .PDF viewer
|
|
Write-Output "Stopping Edge from taking over as the default .PDF viewer"
|
|
$NoOpen = 'HKCR:\.pdf'
|
|
If (!(Get-ItemProperty $NoOpen -Name NoOpenWith)) {
|
|
New-ItemProperty $NoOpen -Name NoOpenWith -Verbose -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
$NoStatic = 'HKCR:\.pdf'
|
|
If (!(Get-ItemProperty $NoStatic -Name NoStaticDefaultVerb)) {
|
|
New-ItemProperty $NoStatic -Name NoStaticDefaultVerb -Verbose -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
$NoOpen = 'HKCR:\.pdf\OpenWithProgids'
|
|
If (!(Get-ItemProperty $NoOpen -Name NoOpenWith)) {
|
|
New-ItemProperty $NoOpen -Name NoOpenWith -Verbose -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
$NoStatic = 'HKCR:\.pdf\OpenWithProgids'
|
|
If (!(Get-ItemProperty $NoStatic -Name NoStaticDefaultVerb)) {
|
|
New-ItemProperty $NoStatic -Name NoStaticDefaultVerb -Verbose -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
$NoOpen = 'HKCR:\.pdf\OpenWithList'
|
|
If (!(Get-ItemProperty $NoOpen -Name NoOpenWith)) {
|
|
New-ItemProperty $NoOpen -Name NoOpenWith -Verbose -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
$NoStatic = 'HKCR:\.pdf\OpenWithList'
|
|
If (!(Get-ItemProperty $NoStatic -Name NoStaticDefaultVerb)) {
|
|
New-ItemProperty $NoStatic -Name NoStaticDefaultVerb -Verbose -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
#Appends an underscore '_' to the Registry key for Edge
|
|
$Edge = 'HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723'
|
|
If (Test-Path $Edge) {
|
|
Set-Item $Edge AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_ -Verbose
|
|
}
|
|
}
|
|
Write-Output "Initiating Sysprep"
|
|
Begin-SysPrep
|
|
Write-Output "Removing bloatware apps."
|
|
Start-Debloat
|
|
Write-Output "Removing leftover bloatware registry keys."
|
|
Remove-Keys
|
|
Write-Output "Stopping telemetry, disabling unneccessary scheduled tasks, and preventing bloatware from returning."
|
|
Protect-Privacy
|
|
Write-Output "Stopping Edge from taking over as the default PDF Viewer."
|
|
Stop-EdgePDF
|
|
Write-Output "Finished all tasks."
|