浏览代码

Optimized DebloatAll and slimmed code more

added ' -and $_.NonRemovable -eq "False"' to the Get-AppxPackage code lines to help sort through apps that can't get deleted and just get skipped anyways.

Onedrive fixes and code reuse from GUI moved over to interactive script code.

Removed [CmdletBinding()] and Param() that wasn't being used.

Fixed Write-Output to Write-Host

Added ' -and $_.NonRemovable -eq "False"' to GUI code as well in the DebloatAll function
Damian 6 年之前
父节点
当前提交
2c587f3fb4
共有 2 个文件被更改,包括 125 次插入156 次删除
  1. 122 145
      Windows10Debloater.ps1
  2. 3 11
      Windows10DebloaterGUI.ps1

+ 122 - 145
Windows10Debloater.ps1

@@ -28,25 +28,17 @@ Start-Transcript -OutputDirectory "$DebloatFolder"
 Add-Type -AssemblyName PresentationCore, PresentationFramework
 Add-Type -AssemblyName PresentationCore, PresentationFramework
 
 
 Function DebloatAll {
 Function DebloatAll {
-    
-    [CmdletBinding()]
-        
-    Param()
-    
     #Removes AppxPackages
     #Removes AppxPackages
     #Credit to /u/GavinEke for a modified version of my whitelist code
     #Credit to /u/GavinEke for a modified version of my whitelist code
-    [regex]$WhitelistedApps = 'Microsoft.ScreenSketch|Microsoft.Paint3D|Microsoft.WindowsCalculator|Microsoft.WindowsStore|Microsoft.Windows.Photos|CanonicalGroupLimited.UbuntuonWindows|`
+    $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.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'
     Microsoft.HEIFImageExtension|Microsoft.ScreenSketch|Microsoft.StorePurchaseApp|Microsoft.VP9VideoExtensions|Microsoft.WebMediaExtensions|Microsoft.WebpImageExtension|Microsoft.DesktopAppInstaller|WindSynthBerry|MIDIBerry|Slack'
-    Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage
-    Get-AppxPackage | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage
-    Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -NotMatch $WhitelistedApps} | Remove-AppxProvisionedPackage -Online
+    Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $WhitelistedApps -and $_.NonRemovable -eq "False"} | Remove-AppxPackage
+    Get-AppxPackage | Where-Object {$_.Name -NotMatch $WhitelistedApps -and $_.NonRemovable -eq "False"} | Remove-AppxPackage
+    Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -NotMatch $WhitelistedApps -and $_.NonRemovable -eq "False"} | Remove-AppxProvisionedPackage -Online
 }
 }
 
 
 Function DebloatBlacklist {
 Function DebloatBlacklist {
-    [CmdletBinding()]
-
-    Param ()
 
 
     $Bloatware = @(
     $Bloatware = @(
 
 
@@ -116,18 +108,14 @@ Function DebloatBlacklist {
         #"*Microsoft.WindowsStore*"
         #"*Microsoft.WindowsStore*"
     )
     )
     foreach ($Bloat in $Bloatware) {
     foreach ($Bloat in $Bloatware) {
-        Get-AppxPackage -Name $Bloat| Remove-AppxPackage -ErrorAction SilentlyContinue
-        Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $Bloat | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue
+        Get-AppxPackage -Name $Bloat| Remove-AppxPackage
+        Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $Bloat | Remove-AppxProvisionedPackage -Online
         Write-Output "Trying to remove $Bloat."
         Write-Output "Trying to remove $Bloat."
     }
     }
 }
 }
 
 
 Function Remove-Keys {
 Function Remove-Keys {
         
         
-    [CmdletBinding()]
-            
-    Param()
-        
     #These are the registry keys that it will delete.
     #These are the registry keys that it will delete.
             
             
     $Keys = @(
     $Keys = @(
@@ -171,10 +159,6 @@ Function Remove-Keys {
 }
 }
             
             
 Function Protect-Privacy {
 Function Protect-Privacy {
-        
-    [CmdletBinding()]
-        
-    Param()
             
             
     #Disables Windows Feedback Experience
     #Disables Windows Feedback Experience
     Write-Output "Disabling Windows Feedback Experience program"
     Write-Output "Disabling Windows Feedback Experience program"
@@ -288,7 +272,7 @@ Function Protect-Privacy {
     Write-Output "Disabling People icon on Taskbar"
     Write-Output "Disabling People icon on Taskbar"
     $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
     $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
     If (Test-Path $People) {
     If (Test-Path $People) {
-        Set-ItemProperty $People -Name PeopleBand -Value 0 -Verbose
+        Set-ItemProperty $People -Name PeopleBand -Value 0
     }
     }
         
         
     #Disables scheduled tasks that are considered unnecessary 
     #Disables scheduled tasks that are considered unnecessary 
@@ -390,10 +374,6 @@ Function Stop-EdgePDF {
 }
 }
 
 
 Function Revert-Changes {   
 Function Revert-Changes {   
-            
-    [CmdletBinding()]
-            
-    Param()
         
         
     #This function will revert the changes you made when running the Start-Debloat function.
     #This function will revert the changes you made when running the Start-Debloat function.
         
         
@@ -538,10 +518,6 @@ Function Enable-EdgePDF {
 
 
 Function FixWhitelistedApps {
 Function FixWhitelistedApps {
     
     
-    [CmdletBinding()]
-            
-    Param()
-    
     If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.Windows.Photos)) {
     If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.Windows.Photos)) {
     
     
         #Credit to abulgatz for these 4 lines of code
         #Credit to abulgatz for these 4 lines of code
@@ -554,88 +530,89 @@ Function FixWhitelistedApps {
 
 
 Function UninstallOneDrive {
 Function UninstallOneDrive {
 
 
-    Write-Output "Checking for pre-existing files and folders located in the OneDrive folders..."
+    Write-Host "Checking for pre-existing files and folders located in the OneDrive folders..."
     Start-Sleep 1
     Start-Sleep 1
-    If (Get-Item -Path "$env:USERPROFILE\OneDrive\*") {
-        Write-Output "Files found within the OneDrive folder! Checking to see if a folder named OneDriveBackupFiles exists."
-        Start-Sleep 1
+    If (Test-Path "$env:USERPROFILE\OneDrive\*") {
+            Write-Host "Files found within the OneDrive folder! Checking to see if a folder named OneDriveBackupFiles exists."
+            Start-Sleep 1
               
               
-        If (Get-Item "$env:USERPROFILE\Desktop\OneDriveBackupFiles" -ErrorAction SilentlyContinue) {
-            Write-Output "A folder named OneDriveBackupFiles already exists on your desktop. All files from your OneDrive location will be moved to that folder." 
-        }
-        else {
-            If (!(Get-Item "$env:USERPROFILE\Desktop\OneDriveBackupFiles" -ErrorAction SilentlyContinue)) {
-                Write-Output "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-Output "Successfully created the folder 'OneDriveBackupFiles' on your desktop."
+            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." 
             }
             }
+            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."
+                }
+            }
+            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
         }
         }
-        Start-Sleep 1
-        Move-Item -Path "$env:USERPROFILE\OneDrive\*" -Destination "$env:USERPROFILE\Desktop\OneDriveBackupFiles" -Force
-        Write-Output "Successfully moved all files/folders from your OneDrive folder to the folder 'OneDriveBackupFiles' on your desktop."
-        Start-Sleep 1
-        Write-Output "Proceeding with the removal of OneDrive."
-        Start-Sleep 1
-    }
-    Else {
-        If (!(Get-Item -Path "$env:USERPROFILE\OneDrive\*")) {
-            Write-Output "Either the OneDrive folder does not exist or there are no files to be found in the folder. Proceeding with removal of OneDrive."
+        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
             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
+                Set-ItemProperty $OneDriveKey -Name OneDrive -Value DisableFileSyncNGSC
+            }
+            Set-ItemProperty $OneDriveKey -Name OneDrive -Value DisableFileSyncNGSC
         }
         }
-    }
 
 
-    Write-Output "Uninstalling OneDrive"
+        Write-Host "Uninstalling OneDrive. Please wait..."
     
     
-    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
-    
-    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 
+        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"
         }
         }
-
-        $DisableAllOneDrive = 'HKLM:Software\Policies\Microsoft\Windows\OneDrive'
-        If (Test-Path $DisableAllOneDrive) {
-            New-ItemProperty $DisableAllOneDrive -Name OneDrive -Value DisableFileSyncNGSC -Verbose 
+        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!"
 }
 }
 
 
 Function UnpinStart {
 Function UnpinStart {
 #https://superuser.com/questions/1068382/how-to-remove-all-the-tiles-in-the-windows-10-start-menu
 #https://superuser.com/questions/1068382/how-to-remove-all-the-tiles-in-the-windows-10-start-menu
 #Unpins all tiles from the Start Menu
 #Unpins all tiles from the Start Menu
-    Write-Output "Unpinning all tiles from the start menu"
+    Write-Host "Unpinning all tiles from the start menu"
     (New-Object -Com Shell.Application).
     (New-Object -Com Shell.Application).
     NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').
     NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').
     Items() |
     Items() |
@@ -646,7 +623,7 @@ Function UnpinStart {
 
 
 Function Remove3dObjects {
 Function Remove3dObjects {
 #Removes 3D Objects from the 'My Computer' submenu in explorer
 #Removes 3D Objects from the 'My Computer' submenu in explorer
-    Write-Output "Removing 3D Objects from explorer 'My Computer' submenu"
+    Write-Host "Removing 3D Objects from explorer 'My Computer' submenu"
     $Objects32 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
     $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}"
     $Objects64 = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
     If (Test-Path $Objects32) {
     If (Test-Path $Objects32) {
@@ -659,7 +636,7 @@ Function Remove3dObjects {
 
 
 Function Restore3dObjects {
 Function Restore3dObjects {
 #Restores 3D Objects from the 'My Computer' submenu in explorer
 #Restores 3D Objects from the 'My Computer' submenu in explorer
-    Write-Output "Restoring 3D Objects from explorer 'My Computer' submenu"
+    Write-Host "Restoring 3D Objects from explorer 'My Computer' submenu"
     $Objects32 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
     $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}"
     $Objects64 = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
     If (!(Test-Path $Objects32)) {
     If (!(Test-Path $Objects32)) {
@@ -698,72 +675,72 @@ Switch ($Prompt1) {
         switch ($Prompt2) {
         switch ($Prompt2) {
             Yes { 
             Yes { 
                 #Creates a "drive" to access the HKCR (HKEY_CLASSES_ROOT)
                 #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."
+                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
                 New-PSDrive  HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
                 Start-Sleep 1
                 Start-Sleep 1
-                Write-Output "Uninstalling bloatware, please wait."
+                Write-Host "Uninstalling bloatware, please wait."
                 DebloatAll
                 DebloatAll
-                Write-Output "Bloatware removed."
+                Write-Host "Bloatware removed."
                 Start-Sleep 1
                 Start-Sleep 1
-                Write-Output "Removing specific registry keys."
+                Write-Host "Removing specific registry keys."
                 Remove-Keys
                 Remove-Keys
-                Write-Output "Leftover bloatware registry keys removed."
+                Write-Host "Leftover bloatware registry keys removed."
                 Start-Sleep 1
                 Start-Sleep 1
-                Write-Output "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
+                Write-Host "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
                 Start-Sleep 1
                 Start-Sleep 1
                 FixWhitelistedApps
                 FixWhitelistedApps
                 Start-Sleep 1
                 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."
+                Write-Host "Disabling Cortana from search, disabling feedback to Microsoft, and disabling scheduled tasks that are considered to be telemetry or unnecessary."
                 Protect-Privacy
                 Protect-Privacy
                 Start-Sleep 1
                 Start-Sleep 1
                 DisableCortana
                 DisableCortana
-                Write-Output "Cortana disabled and removed from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled."
+                Write-Host "Cortana disabled and removed from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled."
                 Start-Sleep 1
                 Start-Sleep 1
-                Write-Output "Stopping and disabling Diagnostics Tracking Service"
+                Write-Host "Stopping and disabling Diagnostics Tracking Service"
                 DisableDiagTrack
                 DisableDiagTrack
-                Write-Output "Diagnostics Tracking Service disabled"
+                Write-Host "Diagnostics Tracking Service disabled"
                 Start-Sleep 1
                 Start-Sleep 1
-                Write-Output "Disabling WAP push service"
+                Write-Host "Disabling WAP push service"
                 DisableWAPPush
                 DisableWAPPush
                 Start-Sleep 1
                 Start-Sleep 1
-                Write-Output "Re-enabling DMWAppushservice if it was disabled"
+                Write-Host "Re-enabling DMWAppushservice if it was disabled"
                 CheckDMWService
                 CheckDMWService
                 Start-Sleep 1
                 Start-Sleep 1
-                Write-Output "Removing 3D Objects from the 'My Computer' submenu in explorer"
+                Write-Host "Removing 3D Objects from the 'My Computer' submenu in explorer"
                 Remove3dObjects
                 Remove3dObjects
                 Start-Sleep 1
                 Start-Sleep 1
             }
             }
             No {
             No {
                 #Creates a "drive" to access the HKCR (HKEY_CLASSES_ROOT)
                 #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."
+                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
                 New-PSDrive  HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
                 Start-Sleep 1
                 Start-Sleep 1
-                Write-Output "Uninstalling bloatware, please wait."
+                Write-Host "Uninstalling bloatware, please wait."
                 DebloatBlacklist
                 DebloatBlacklist
-                Write-Output "Bloatware removed."
+                Write-Host "Bloatware removed."
                 Start-Sleep 1
                 Start-Sleep 1
-                Write-Output "Removing specific registry keys."
+                Write-Host "Removing specific registry keys."
                 Remove-Keys
                 Remove-Keys
-                Write-Output "Leftover bloatware registry keys removed."
+                Write-Host "Leftover bloatware registry keys removed."
                 Start-Sleep 1
                 Start-Sleep 1
-                Write-Output "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
+                Write-Host "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
                 Start-Sleep 1
                 Start-Sleep 1
                 FixWhitelistedApps
                 FixWhitelistedApps
                 Start-Sleep 1
                 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."
+                Write-Host "Disabling Cortana from search, disabling feedback to Microsoft, and disabling scheduled tasks that are considered to be telemetry or unnecessary."
                 Protect-Privacy
                 Protect-Privacy
                 Start-Sleep 1
                 Start-Sleep 1
                 DisableCortana
                 DisableCortana
-                Write-Output "Cortana disabled and removed from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled."
+                Write-Host "Cortana disabled and removed from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled."
                 Start-Sleep 1
                 Start-Sleep 1
-                Write-Output "Stopping and disabling Diagnostics Tracking Service"
+                Write-Host "Stopping and disabling Diagnostics Tracking Service"
                 DisableDiagTrack
                 DisableDiagTrack
-                Write-Output "Diagnostics Tracking Service disabled"
+                Write-Host "Diagnostics Tracking Service disabled"
                 Start-Sleep 1
                 Start-Sleep 1
-                Write-Output "Disabling WAP push service"
+                Write-Host "Disabling WAP push service"
                 Start-Sleep 1
                 Start-Sleep 1
                 DisableWAPPush
                 DisableWAPPush
-                Write-Output "Re-enabling DMWAppushservice if it was disabled"
+                Write-Host "Re-enabling DMWAppushservice if it was disabled"
                 CheckDMWService
                 CheckDMWService
                 Start-Sleep 1
                 Start-Sleep 1
             }
             }
@@ -773,10 +750,10 @@ Switch ($Prompt1) {
         Switch ($Prompt3) {
         Switch ($Prompt3) {
             Yes {
             Yes {
                 Stop-EdgePDF
                 Stop-EdgePDF
-                Write-Output "Edge will no longer take over as the default PDF viewer."
+                Write-Host "Edge will no longer take over as the default PDF viewer."
             }
             }
             No {
             No {
-                Write-Output "You chose not to stop Edge from taking over as the default PDF viewer."
+                Write-Host "You chose not to stop Edge from taking over as the default PDF viewer."
             }
             }
         }
         }
         #Prompt asking to delete OneDrive
         #Prompt asking to delete OneDrive
@@ -784,10 +761,10 @@ Switch ($Prompt1) {
         Switch ($Prompt4) {
         Switch ($Prompt4) {
             Yes {
             Yes {
                 UninstallOneDrive
                 UninstallOneDrive
-                Write-Output "OneDrive is now removed from the computer."
+                Write-Host "OneDrive is now removed from the computer."
             }
             }
             No {
             No {
-                Write-Output "You have chosen to skip removing OneDrive from your machine."
+                Write-Host "You have chosen to skip removing OneDrive from your machine."
             }
             }
         }
         }
 				#Prompt asking if you'd like to unpin all start items
 				#Prompt asking if you'd like to unpin all start items
@@ -795,20 +772,20 @@ Switch ($Prompt1) {
         Switch ($Prompt5) {
         Switch ($Prompt5) {
             Yes {
             Yes {
                 UnpinStart
                 UnpinStart
-				Write-Output "Start Apps unpined."
+				Write-Host "Start Apps unpined."
             }
             }
             No {
             No {
-				Write-Output "You have chosen to skip removing OneDrive from your machine."
+				Write-Host "You have chosen to skip removing OneDrive from your machine."
 
 
             }
             }
         }
         }
         $Prompt6 = [Windows.MessageBox]::Show($InstallNET, "Install .Net", $Button, $Warn)
         $Prompt6 = [Windows.MessageBox]::Show($InstallNET, "Install .Net", $Button, $Warn)
         Switch ($Prompt6) {
         Switch ($Prompt6) {
             Yes {
             Yes {
-                Write-Output "Initializing the installation of .NET 3.5..."
+                Write-Host "Initializing the installation of .NET 3.5..."
                 Try {
                 Try {
                 DISM /Online /Enable-Feature /FeatureName:NetFx3 /All
                 DISM /Online /Enable-Feature /FeatureName:NetFx3 /All
-                Write-Output ".NET 3.5 has been successfully installed!" }
+                Write-Host ".NET 3.5 has been successfully installed!" }
                 Catch {
                 Catch {
                     $_
                     $_
                 }
                 }
@@ -818,28 +795,28 @@ Switch ($Prompt1) {
         $Prompt7 = [Windows.MessageBox]::Show($Reboot, "Reboot", $Button, $Warn) 
         $Prompt7 = [Windows.MessageBox]::Show($Reboot, "Reboot", $Button, $Warn) 
         Switch ($Prompt7) {
         Switch ($Prompt7) {
             Yes {
             Yes {
-                Write-Output "Unloading the HKCR drive..."
+                Write-Host "Unloading the HKCR drive..."
                 Remove-PSDrive HKCR 
                 Remove-PSDrive HKCR 
                 Start-Sleep 1
                 Start-Sleep 1
                 Stop-Transcript
                 Stop-Transcript
-                Write-Output "Initiating reboot."
+                Write-Host "Initiating reboot."
                 Start-Sleep 2
                 Start-Sleep 2
                 Restart-Computer
                 Restart-Computer
             }
             }
             No {
             No {
-                Write-Output "Unloading the HKCR drive..."
+                Write-Host "Unloading the HKCR drive..."
                 Remove-PSDrive HKCR 
                 Remove-PSDrive HKCR 
                 Start-Sleep 1
                 Start-Sleep 1
                 Stop-Transcript
                 Stop-Transcript
-                Write-Output "Script has finished. Exiting."
+                Write-Host "Script has finished. Exiting."
                 Start-Sleep 2
                 Start-Sleep 2
                 Exit
                 Exit
             }
             }
         }
         }
     }
     }
     No {
     No {
-        Write-Output "Reverting changes..."
-        Write-Output "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."
+        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
         New-PSDrive  HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
         Revert-Changes
         Revert-Changes
         #Prompt asking to revert edge changes as well
         #Prompt asking to revert edge changes as well
@@ -847,29 +824,29 @@ Switch ($Prompt1) {
         Switch ($Prompt6) {
         Switch ($Prompt6) {
             Yes {
             Yes {
                 Enable-EdgePDF
                 Enable-EdgePDF
-                Write-Output "Edge will no longer be disabled from being used as the default Edge PDF viewer."
+                Write-Host "Edge will no longer be disabled from being used as the default Edge PDF viewer."
             }
             }
             No {
             No {
-               Write-Output "You have chosen to keep the setting that disallows Edge to be the default PDF viewer."
+               Write-Host "You have chosen to keep the setting that disallows Edge to be the default PDF viewer."
             }
             }
         }
         }
         #Prompt asking if you'd like to reboot your machine
         #Prompt asking if you'd like to reboot your machine
         $Prompt7 = [Windows.MessageBox]::Show($Reboot, "Reboot", $Button, $Warn)
         $Prompt7 = [Windows.MessageBox]::Show($Reboot, "Reboot", $Button, $Warn)
         Switch ($Prompt7) {
         Switch ($Prompt7) {
             Yes {
             Yes {
-                Write-Output "Unloading the HKCR drive..."
+                Write-Host "Unloading the HKCR drive..."
                 Remove-PSDrive HKCR 
                 Remove-PSDrive HKCR 
                 Start-Sleep 1
                 Start-Sleep 1
-                Write-Output "Initiating reboot."
+                Write-Host "Initiating reboot."
                 Stop-Transcript
                 Stop-Transcript
                 Start-Sleep 2
                 Start-Sleep 2
                 Restart-Computer
                 Restart-Computer
             }
             }
             No {
             No {
-                Write-Output "Unloading the HKCR drive..."
+                Write-Host "Unloading the HKCR drive..."
                 Remove-PSDrive HKCR 
                 Remove-PSDrive HKCR 
                 Start-Sleep 1
                 Start-Sleep 1
-                Write-Output "Script has finished. Exiting."
+                Write-Host "Script has finished. Exiting."
                 Stop-Transcript
                 Stop-Transcript
                 Start-Sleep 2
                 Start-Sleep 2
                 Exit
                 Exit

+ 3 - 11
Windows10DebloaterGUI.ps1

@@ -158,9 +158,6 @@ Start-Transcript -OutputDirectory "$DebloatFolder"
 $RemoveBlacklist.Add_Click( { 
 $RemoveBlacklist.Add_Click( { 
         $ErrorActionPreference = 'silentlycontinue'
         $ErrorActionPreference = 'silentlycontinue'
         Function DebloatBlacklist {
         Function DebloatBlacklist {
-            [CmdletBinding()]
-    
-            Param ()
     
     
             $Bloatware = @(
             $Bloatware = @(
     
     
@@ -246,7 +243,6 @@ $RemoveAllBloatware.Add_Click( {
         #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.
         #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.
 
 
         Function Begin-SysPrep {
         Function Begin-SysPrep {
-            $ErrorActionPreference = 'silentlycontinue'
 
 
             Write-Host "Starting Sysprep Fixes"
             Write-Host "Starting Sysprep Fixes"
    
    
@@ -281,18 +277,14 @@ $RemoveAllBloatware.Add_Click( {
 
 
         Function DebloatAll {
         Function DebloatAll {
     
     
-            [CmdletBinding()]
-        
-            Param()
-    
             #Removes AppxPackages
             #Removes AppxPackages
             #Credit to /u/GavinEke for a modified version of my whitelist code
             #Credit to /u/GavinEke for a modified version of my whitelist code
             [regex]$WhitelistedApps = 'Microsoft.ScreenSketch|Microsoft.Paint3D|Microsoft.WindowsCalculator|Microsoft.WindowsStore|Microsoft.Windows.Photos|CanonicalGroupLimited.UbuntuonWindows|`
             [regex]$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.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'
             Microsoft.HEIFImageExtension|Microsoft.ScreenSketch|Microsoft.StorePurchaseApp|Microsoft.VP9VideoExtensions|Microsoft.WebMediaExtensions|Microsoft.WebpImageExtension|Microsoft.DesktopAppInstaller|WindSynthBerry|MIDIBerry|Slack'
-            Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage
-            Get-AppxPackage | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage
-            Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -NotMatch $WhitelistedApps} | Remove-AppxProvisionedPackage -Online
+            Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $WhitelistedApps -and $_.NonRemovable -eq "False"} | Remove-AppxPackage
+            Get-AppxPackage | Where-Object {$_.Name -NotMatch $WhitelistedApps -and $_.NonRemovable -eq "False"} | Remove-AppxPackage
+            Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -NotMatch $WhitelistedApps -and $_.NonRemovable -eq "False"} | Remove-AppxProvisionedPackage -Online
         }
         }
   
   
         #Creates a PSDrive to be able to access the 'HKCR' tree
         #Creates a PSDrive to be able to access the 'HKCR' tree