From ae7fd52b09d8484d8f43eb63cace0d36273cf0b0 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 25 Jul 2018 15:10:05 +0100 Subject: [PATCH 1/5] added Extra steps to remove provisioned packages. Added registry keys to stop autoupdates on Windows Store Added step to stop installer service --- Windows10SysPrepDebloater.ps1 | 92 ++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/Windows10SysPrepDebloater.ps1 b/Windows10SysPrepDebloater.ps1 index 3cb17f5..db78668 100644 --- a/Windows10SysPrepDebloater.ps1 +++ b/Windows10SysPrepDebloater.ps1 @@ -7,13 +7,103 @@ param ( [switch]$Debloat, [switch]$SysPrep, [switch]$StopEdgePDF ) +Function Remove-AppxPackagesForSysprep { +$AppXApps = @( + + #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*" + + #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 ($App in $AppXApps) { + Get-AppxPackage -Name $App | Remove-AppxPackage -ErrorAction SilentlyContinue + Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $App | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue + } + +} + #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 -ErrorAction SilentlyContinue - + Remove-AppxPackagesForSysprep -ErrorAction SilentlyContinue + # Disable Windows Store Automatic Updates + Write-Output "Adding Registry key to Disable Windows Store Automatic Updates" + $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\WindowsStore" + If (!(Test-Path $registryPath)) { + Mkdir $registryPath -ErrorAction SilentlyContinue + New-ItemProperty $registryPath -Name AutoDownload -Value 2 -Verbose -ErrorAction SilentlyContinue + } + Else { + Set-ItemProperty $registryPath -Name AutoDownload -Value 2 -Verbose -ErrorAction SilentlyContinue + } + # Disable Microsoft Consumer Experience + 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 + } + Else{ + Set-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 1 -Verbose -ErrorAction SilentlyContinue + } + #Stop WindowsStore Installer Service and set to Disabled + net stop InstallService + sc config InstallService start=disabled } #Creates a PSDrive to be able to access the 'HKCR' tree From 30541754f63b764d25a6a4eb44a469eede1e29f7 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 25 Jul 2018 16:36:27 +0100 Subject: [PATCH 2/5] Fixed logic to make use of the switches --- Windows10SysPrepDebloater.ps1 | 574 +++++++++++++++++----------------- 1 file changed, 291 insertions(+), 283 deletions(-) diff --git a/Windows10SysPrepDebloater.ps1 b/Windows10SysPrepDebloater.ps1 index db78668..7621445 100644 --- a/Windows10SysPrepDebloater.ps1 +++ b/Windows10SysPrepDebloater.ps1 @@ -4,71 +4,71 @@ #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, [switch]$SysPrep, [switch]$StopEdgePDF + [switch]$Debloat, [switch]$SysPrep, [switch]$StopEdgePDF ) - +$ErrorActionPreference = 'SilentlyContinue' Function Remove-AppxPackagesForSysprep { -$AppXApps = @( - - #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*" - - #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*" + $AppXApps = @( + + #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*" + + #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 ($App in $AppXApps) { - Get-AppxPackage -Name $App | Remove-AppxPackage -ErrorAction SilentlyContinue - Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $App | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue + foreach ($App in $AppXApps) { + Get-AppxPackage -Name $App | Remove-AppxPackage -ErrorAction SilentlyContinue + Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $App | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue } } @@ -77,254 +77,262 @@ foreach ($App in $AppXApps) { Function Begin-SysPrep { param([switch]$SysPrep) - - get-appxpackage | remove-appxpackage -ErrorAction SilentlyContinue - Remove-AppxPackagesForSysprep -ErrorAction SilentlyContinue - # Disable Windows Store Automatic Updates - Write-Output "Adding Registry key to Disable Windows Store Automatic Updates" - $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\WindowsStore" - If (!(Test-Path $registryPath)) { - Mkdir $registryPath -ErrorAction SilentlyContinue - New-ItemProperty $registryPath -Name AutoDownload -Value 2 -Verbose -ErrorAction SilentlyContinue + IF ($SysPrep) { + get-appxpackage | remove-appxpackage -ErrorAction SilentlyContinue + Remove-AppxPackagesForSysprep -ErrorAction SilentlyContinue + # Disable Windows Store Automatic Updates + Write-Output "Adding Registry key to Disable Windows Store Automatic Updates" + $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\WindowsStore" + If (!(Test-Path $registryPath)) { + Mkdir $registryPath -ErrorAction SilentlyContinue + New-ItemProperty $registryPath -Name AutoDownload -Value 2 -Verbose -ErrorAction SilentlyContinue + } + Else { + Set-ItemProperty $registryPath -Name AutoDownload -Value 2 -Verbose -ErrorAction SilentlyContinue + } + # Disable Microsoft Consumer Experience + 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 + } + Else { + Set-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 1 -Verbose -ErrorAction SilentlyContinue + } + #Stop WindowsStore Installer Service and set to Disabled + Stop-Service InstallService + sc config InstallService start=disabled } - Else { - Set-ItemProperty $registryPath -Name AutoDownload -Value 2 -Verbose -ErrorAction SilentlyContinue - } - # Disable Microsoft Consumer Experience - 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 - } - Else{ - Set-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 1 -Verbose -ErrorAction SilentlyContinue - } - #Stop WindowsStore Installer Service and set to Disabled - net stop InstallService - sc config InstallService start=disabled } -#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 - #Credit to Reddit user /u/GavinEke for a modified version of my whitelist code - [regex]$WhitelistedApps = 'Microsoft.Paint3D|Microsoft.WindowsCalculator|Microsoft.WindowsStore|Microsoft.Windows.Photos|CanonicalGroupLimited.UbuntuonWindows' - Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage -ErrorAction SilentlyContinue - Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -NotMatch $WhitelistedApps} | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue +Function Start-Debloat { + + param([switch]$Debloat) + IF ($Debloat) { + #Removes AppxPackages + #Credit to Reddit user /u/GavinEke for a modified version of my whitelist code + [regex]$WhitelistedApps = 'Microsoft.Paint3D|Microsoft.WindowsCalculator|Microsoft.WindowsStore|Microsoft.Windows.Photos|CanonicalGroupLimited.UbuntuonWindows' + Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage -ErrorAction SilentlyContinue + Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -NotMatch $WhitelistedApps} | 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 + + Param([switch]$Debloat) + if ($Debloat) { + #Creates a PSDrive to be able to access the 'HKCR' tree + New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT + #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 - } + Param([switch]$Debloat) + if ($Debloat) { + #Creates a PSDrive to be able to access the 'HKCR' tree + New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT - #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 - } + #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 + } - #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 -ErrorAction SilentlyContinue - Get-ScheduledTask -TaskName XblGameSaveTask | Disable-ScheduledTask -ErrorAction SilentlyContinue - Get-ScheduledTask -TaskName Consolidator | Disable-ScheduledTask -ErrorAction SilentlyContinue - Get-ScheduledTask -TaskName UsbCeip | Disable-ScheduledTask -ErrorAction SilentlyContinue - Get-ScheduledTask -TaskName DmClient | Disable-ScheduledTask -ErrorAction SilentlyContinue - Get-ScheduledTask -TaskName DmClientOnScenarioDownload | Disable-ScheduledTask -ErrorAction SilentlyContinue + #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 -ErrorAction SilentlyContinue + Get-ScheduledTask -TaskName XblGameSaveTask | Disable-ScheduledTask -ErrorAction SilentlyContinue + Get-ScheduledTask -TaskName Consolidator | Disable-ScheduledTask -ErrorAction SilentlyContinue + Get-ScheduledTask -TaskName UsbCeip | Disable-ScheduledTask -ErrorAction SilentlyContinue + Get-ScheduledTask -TaskName DmClient | Disable-ScheduledTask -ErrorAction SilentlyContinue + Get-ScheduledTask -TaskName DmClientOnScenarioDownload | Disable-ScheduledTask -ErrorAction SilentlyContinue + } } - + 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 + param([switch]$StopEdgePDF) + IF ($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 + } } } Function FixWhitelistedApps { - + Param([switch]$Debloat) - - If(!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.Windows.Photos)) { - - #Credit to abulgatz for the 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"} } + IF ($Debloat) { + If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.Windows.Photos)) { + + #Credit to abulgatz for the 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"} + } + } } Write-Output "Initiating Sysprep" -Begin-SysPrep +Begin-SysPrep @PSBoundParameters Write-Output "Removing bloatware apps." -Start-Debloat +Start-Debloat @PSBoundParameters Write-Output "Removing leftover bloatware registry keys." -Remove-Keys +Remove-Keys @PSBoundParameters Write-Output "Checking to see if any Whitelisted Apps were removed, and if so re-adding them." -FixWhitelistedApps +FixWhitelistedApps @PSBoundParameters Write-Output "Stopping telemetry, disabling unneccessary scheduled tasks, and preventing bloatware from returning." -Protect-Privacy +Protect-Privacy @PSBoundParameters Write-Output "Stopping Edge from taking over as the default PDF Viewer." -Stop-EdgePDF +Stop-EdgePDF @PSBoundParameters Write-Output "Finished all tasks." From d770bf1f2bc731369982bd598d60c0555c8b5d8c Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 25 Jul 2018 16:37:40 +0100 Subject: [PATCH 3/5] Fixed Sc command --- Windows10SysPrepDebloater.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Windows10SysPrepDebloater.ps1 b/Windows10SysPrepDebloater.ps1 index 7621445..5e1a447 100644 --- a/Windows10SysPrepDebloater.ps1 +++ b/Windows10SysPrepDebloater.ps1 @@ -103,7 +103,7 @@ Function Begin-SysPrep { } #Stop WindowsStore Installer Service and set to Disabled Stop-Service InstallService - sc config InstallService start=disabled + & sc config InstallService start=disabled } } @@ -318,7 +318,7 @@ Function FixWhitelistedApps { 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"} + Get-AppxPackage -allusers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} } } } From 4caf494048380dad58f55c8d6462776402492d43 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 25 Jul 2018 17:09:03 +0100 Subject: [PATCH 4/5] fixed error with apps installed as other users --- Windows10SysPrepDebloater.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/Windows10SysPrepDebloater.ps1 b/Windows10SysPrepDebloater.ps1 index 5e1a447..e2c002e 100644 --- a/Windows10SysPrepDebloater.ps1 +++ b/Windows10SysPrepDebloater.ps1 @@ -68,6 +68,7 @@ Function Remove-AppxPackagesForSysprep { ) foreach ($App in $AppXApps) { Get-AppxPackage -Name $App | Remove-AppxPackage -ErrorAction SilentlyContinue + Get-AppxPackage -Name $App -AllUsers | Remove-AppxPackage -AllUsers -ErrorAction SilentlyContinue Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $App | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue } From 48548774594d2ec2229f4f9637f6d858dd968af2 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 26 Jul 2018 11:43:31 +0100 Subject: [PATCH 5/5] Added Privacy switch and added verbose messaging so that it appears in the MDT logs --- Windows10SysPrepDebloater.ps1 | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/Windows10SysPrepDebloater.ps1 b/Windows10SysPrepDebloater.ps1 index e2c002e..9888ab4 100644 --- a/Windows10SysPrepDebloater.ps1 +++ b/Windows10SysPrepDebloater.ps1 @@ -4,7 +4,7 @@ #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, [switch]$SysPrep, [switch]$StopEdgePDF + [switch]$Debloat, [switch]$SysPrep, [switch]$StopEdgePDF, [Switch]$Privacy ) $ErrorActionPreference = 'SilentlyContinue' Function Remove-AppxPackagesForSysprep { @@ -67,6 +67,7 @@ Function Remove-AppxPackagesForSysprep { #"*Microsoft.WindowsStore*" ) foreach ($App in $AppXApps) { + Write-Verbose -Message ('Removing Package {0}' -f $App) Get-AppxPackage -Name $App | Remove-AppxPackage -ErrorAction SilentlyContinue Get-AppxPackage -Name $App -AllUsers | Remove-AppxPackage -AllUsers -ErrorAction SilentlyContinue Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $App | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue @@ -79,31 +80,35 @@ Function Begin-SysPrep { param([switch]$SysPrep) IF ($SysPrep) { + Write-Verbose -Message ('Starting Sysprep Fixes') + Write-Verbose -Message ('Removing AppXPackages for current user') get-appxpackage | remove-appxpackage -ErrorAction SilentlyContinue Remove-AppxPackagesForSysprep -ErrorAction SilentlyContinue # Disable Windows Store Automatic Updates - Write-Output "Adding Registry key to Disable Windows Store Automatic Updates" + Write-Verbose -Message "Adding Registry key to Disable Windows Store Automatic Updates" $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\WindowsStore" If (!(Test-Path $registryPath)) { Mkdir $registryPath -ErrorAction SilentlyContinue - New-ItemProperty $registryPath -Name AutoDownload -Value 2 -Verbose -ErrorAction SilentlyContinue + New-ItemProperty $registryPath -Name AutoDownload -Value 2 -ErrorAction SilentlyContinue } Else { - Set-ItemProperty $registryPath -Name AutoDownload -Value 2 -Verbose -ErrorAction SilentlyContinue + Set-ItemProperty $registryPath -Name AutoDownload -Value 2 -ErrorAction SilentlyContinue } # Disable Microsoft Consumer Experience - Write-Output "Adding Registry key to prevent bloatware apps from returning" + Write-Verbose -Message "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 + New-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 1 -ErrorAction SilentlyContinue } Else { - Set-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 1 -Verbose -ErrorAction SilentlyContinue + Set-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 1 -ErrorAction SilentlyContinue } #Stop WindowsStore Installer Service and set to Disabled + Write-Verbose -Message ('Stopping InstallService') Stop-Service InstallService + Write-Verbose -Message ('Setting InstallService Startup to Disabled') & sc config InstallService start=disabled } } @@ -115,6 +120,7 @@ Function Start-Debloat { IF ($Debloat) { #Removes AppxPackages #Credit to Reddit user /u/GavinEke for a modified version of my whitelist code + Write-Verbose -Message ('Starting Debloat') [regex]$WhitelistedApps = 'Microsoft.Paint3D|Microsoft.WindowsCalculator|Microsoft.WindowsStore|Microsoft.Windows.Photos|CanonicalGroupLimited.UbuntuonWindows' Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage -ErrorAction SilentlyContinue Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -NotMatch $WhitelistedApps} | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue @@ -172,8 +178,9 @@ Function Remove-Keys { Function Protect-Privacy { - Param([switch]$Debloat) - if ($Debloat) { + Param([switch]$Privacy) + if ($Privacy) { + Write-Verbose -Message ('Starting Protect Privacy') #Creates a PSDrive to be able to access the 'HKCR' tree New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT @@ -269,6 +276,7 @@ Function Stop-EdgePDF { param([switch]$StopEdgePDF) IF ($StopEdgePDF) { + Write-Verbose -Message ('Starting StopEdge PDF') #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' @@ -311,8 +319,9 @@ Function Stop-EdgePDF { Function FixWhitelistedApps { - Param([switch]$Debloat) - IF ($Debloat) { + Param([switch]$Debloat, [switch]$SysPrep) + IF ($Debloat -or $SysPrep) { + Write-Verbose -Message ('Starting Fix Whitelisted Apps') If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.Windows.Photos)) { #Credit to abulgatz for the 4 lines of code