From 1b848f8e066b6ce2f2f2a070fc484d52d68b6cda Mon Sep 17 00:00:00 2001 From: Raphire <9938813+Raphire@users.noreply.github.com> Date: Wed, 31 Jan 2024 22:19:50 +0100 Subject: [PATCH] Minor change to custom mode options. Linting. --- README.md | 32 ++++++------ Win11Debloat.ps1 | 125 ++++++++++++++++++++--------------------------- 2 files changed, 69 insertions(+), 88 deletions(-) diff --git a/README.md b/README.md index b6109e8..1b50429 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Win11Debloat -Win11Debloat is a simple and lightweight powershell script that removes pre-installed windows bloatware apps, disables telemetry and declutters the experience by disabling or removing intrusive interface elements, ads and more. No need to painstakingly go through all the settings yourself, or remove apps one by one. Win11Debloat makes the process quick and easy! +Win11Debloat is a simple and lightweight powershell script that removes pre-installed Windows bloatware apps, disables telemetry and declutters the experience by disabling or removing intrusive interface elements, ads and more. No need to painstakingly go through all the settings yourself, or remove apps one by one. Win11Debloat makes the process quick and easy! You can pick and choose exactly which modifications you want the script to make, or use the default settings. If you are unhappy with any of the changes you can easily revert them by using the registry files that are included in the 'Regfiles' folder, all of the apps that are removed can be reinstalled from the Microsoft store. @@ -14,32 +14,32 @@ You can pick and choose exactly which modifications you want the script to make, - Remove all bloatware apps from [this list](#apps-that-are-removed). - Disable telemetry, diagnostic data, app-launch tracking & targeted ads. -- Disable bing search & cortana in windows search. -- Disable tips, tricks, suggestions and ads in start, settings, notifications, windows explorer, and on the lockscreen. +- Disable bing search & cortana in Windows search. +- Disable tips, tricks, suggestions and ads in start, settings, notifications, Windows explorer, and on the lockscreen. - Disable Windows Copilot. (Windows 11 only) - Show file extensions for known file types. - Disable the widget service & hide the icon from the taskbar. - Hide the Chat (meet now) icon from the taskbar. -- Hide the 3D objects folder under 'This pc' in windows explorer. (Windows 10 only) +- Hide the 3D objects folder under 'This pc' in Windows explorer. (Windows 10 only) ### All Features - Remove all bloatware apps from [this list](#apps-that-are-removed) and optionally also remove communication and gaming-related apps. - Remove all pinned apps from the start menu. NOTE: This applies to all existing and new users. (Windows 11 only) - Disable telemetry, diagnostic data, app-launch tracking & targeted ads. -- Disable bing search, bing AI & cortana in windows search. -- Disable tips, tricks, suggestions and ads in start, settings, notifications, windows explorer, and on the lockscreen. +- Disable bing search, bing AI & cortana in Windows search. +- Disable tips, tricks, suggestions and ads in start, settings, notifications, Windows explorer, and on the lockscreen. - Disable Windows Copilot. (Windows 11 only) - Restore the old Windows 10 style context menu. (Windows 11 only) - Show hidden files, folders and drives. - Show file extensions for known file types. -- Hide duplicate removable drive entries from the windows explorer navigation pane, so only the entry under 'This PC' remains. +- Hide duplicate removable drive entries from the Windows explorer navigation pane, so only the entry under 'This PC' remains. - Align taskbar icons to the left. (Windows 11 only) - Hide or change the search icon/box on the taskbar. (Windows 11 only) - Hide the taskview button from the taskbar. (Windows 11 only) - Disable the widget service & hide icon from the taskbar. - Hide the chat (meet now) icon from the taskbar. -- Hide the 3D objects, music or onedrive folder in the windows explorer sidepanel. (Windows 10 only) +- Hide the 3D objects, music or onedrive folder in the Windows explorer sidepanel. (Windows 10 only) - Hide the 'Include in library', 'Give access to' and 'Share' options in the context menu. (Windows 10 only)
@@ -165,7 +165,7 @@ You can pick and choose exactly which modifications you want the script to make, - Microsoft.WindowsCamera - Microsoft.windowscommunicationsapps** (Mail & Calendar) - Microsoft.WindowsStore (Microsoft Store, NOTE: This app cannot be reinstalled!) - - Microsoft.WindowsTerminal (New default terminal app in windows 11) + - Microsoft.WindowsTerminal (New default terminal app in Windows 11) - Microsoft.YourPhone (Phone Link) - Microsoft.Xbox.TCUI (UI framework, removing this may break MS store, photos and certain games) - Microsoft.ZuneMusic (Modern Media Player) @@ -195,7 +195,7 @@ You can pick and choose exactly which modifications you want the script to make, 1. [Download the latest version of the script](https://github.com/Raphire/Win11Debloat/archive/master.zip), and extract the .ZIP file to your desired location. 2. Navigate to the Win11Debloat folder 3. Double click the 'Run.bat' file to start the script. Note: If the console window immediately closes and nothing happens, try the advanced method below. -4. Accept the windows UAC prompt to run the script as administrator, this is required for the script to function. +4. Accept the Windows UAC prompt to run the script as administrator, this is required for the script to function. 5. A new powershell window will now open, showing the Win11Debloat menu. Select either the default or custom setup to continue. 6. Carefully read through and follow the on-screen instructions. @@ -225,13 +225,13 @@ To run the script without any user input, simply add parameters at the end, exam | -RemoveGamingApps | Remove the Xbox App and Xbox Gamebar. | | -ClearStart | Remove all pinned apps from the start menu. NOTE: This applies to all existing and new users. (Windows 11 update 22H2 or later only) | | -DisableTelemetry | Disable telemetry, diagnostic data & targeted ads. | -| -DisableBing | Disable bing search, bing AI & cortana in windows search. | -| -DisableSuggestions | Disable tips, tricks, suggestions and ads in start, settings, notifications and windows explorer. | +| -DisableBing | Disable bing search, bing AI & cortana in Windows search. | +| -DisableSuggestions | Disable tips, tricks, suggestions and ads in start, settings, notifications and Windows explorer. | |
-DisableLockscreenTips
| Disable tips & tricks on the lockscreen. | | -RevertContextMenu | Restore the old Windows 10 style context menu. (Windows 11 only) | | -ShowHiddenFolders | Show hidden files, folders and drives. | | -ShowKnownFileExt | Show file extensions for known file types. | -| -HideDupliDrive | Hide duplicate removable drive entries from the windows explorer navigation pane, so only the entry under 'This PC' remains. | +| -HideDupliDrive | Hide duplicate removable drive entries from the Windows explorer navigation pane, so only the entry under 'This PC' remains. | | -TaskbarAlignLeft | Align taskbar icons to the left. (Windows 11 only) | | -HideSearchTb | Hide search icon from the taskbar. (Windows 11 only) | | -ShowSearchIconTb | Show search icon on the taskbar. (Windows 11 only) | @@ -241,9 +241,9 @@ To run the script without any user input, simply add parameters at the end, exam | -DisableCopilot | Disable Windows copilot. (Windows 11 only) | | -DisableWidgets | Disable the widget service & hide the widget (news and interests) icon from the taskbar. | | -HideChat | Hide the chat (meet now) icon from the taskbar. | -| -HideOnedrive | Hide the onedrive folder in the windows explorer sidepanel. (Windows 10 only) | -| -Hide3dObjects | Hide the 3D objects folder under 'This pc' in windows explorer. (Windows 10 only) | -| -HideMusic | Hide the music folder under 'This pc' in windows explorer. (Windows 10 only) | +| -HideOnedrive | Hide the onedrive folder in the Windows explorer sidepanel. (Windows 10 only) | +| -Hide3dObjects | Hide the 3D objects folder under 'This pc' in Windows explorer. (Windows 10 only) | +| -HideMusic | Hide the music folder under 'This pc' in Windows explorer. (Windows 10 only) | | -HideIncludeInLibrary | Hide the 'Include in library' option in the context menu. (Windows 10 only) | | -HideGiveAccessTo | Hide the 'Give access to' option in the context menu. (Windows 10 only) | | -HideShare | Hide the 'Share' option in the context menu. (Windows 10 only) | diff --git a/Win11Debloat.ps1 b/Win11Debloat.ps1 index c7bfa4c..2027e94 100644 --- a/Win11Debloat.ps1 +++ b/Win11Debloat.ps1 @@ -1,8 +1,7 @@ #Requires -RunAsAdministrator [CmdletBinding(SupportsShouldProcess)] -param -( +param ( [Parameter(ValueFromPipeline = $true)][switch]$Silent, [Parameter(ValueFromPipeline = $true)][switch]$RunDefaults, [Parameter(ValueFromPipeline = $true)][switch]$RunWin11Defaults, @@ -51,7 +50,7 @@ param # Reads list of apps from file and removes them for all user accounts and from the OS image. function RemoveApps { - param( + param ( $appsFile, $message ) @@ -59,8 +58,7 @@ function RemoveApps { Write-Output $message # Get list of apps from file at the path provided, and remove them one by one - Foreach ($app in (Get-Content -Path $appsFile | Where-Object { $_ -notmatch '^#.*' -and $_ -notmatch '^\s*$' } )) - { + Foreach ($app in (Get-Content -Path $appsFile | Where-Object { $_ -notmatch '^#.*' -and $_ -notmatch '^\s*$' } )) { # Remove any spaces before and after the Appname $app = $app.Trim() @@ -89,13 +87,11 @@ function RemoveApps { # Removes apps specified during function call from all user accounts and from the OS image. function RemoveSpecificApps { - param - ( + param ( $appslist ) - Foreach ($app in $appsList) - { + Foreach ($app in $appsList) { $appString = $app.Trim('*') Write-Output "Attempting to remove $appString..." @@ -110,8 +106,7 @@ function RemoveSpecificApps { # Import & execute regfile function RegImport { - param - ( + param ( $message, $path ) @@ -122,9 +117,9 @@ function RegImport { } -# Stop & Restart the windows explorer process +# Stop & Restart the Windows explorer process function RestartExplorer { - Write-Output "> Restarting windows explorer to apply all changes." + Write-Output "> Restarting Windows explorer to apply all changes." Start-Sleep 0.5 @@ -139,7 +134,7 @@ function RestartExplorer { # Clear all pinned apps from the start menu. # Credit: https://lazyadmin.nl/win-11/customize-windows-11-start-menu-layout/ function ClearStartMenu { - param( + param ( $message ) @@ -163,7 +158,7 @@ function ClearStartMenu { Write-Output $cpyMsg } else { - # Bin file doesn't exist, indicating the user is not running the correct version of windows. Exit function + # Bin file doesn't exist, indicating the user is not running the correct version of Windows. Exit function Write-Output "Error: Start menu file not found. Please make sure you're running Windows 11 22H2 or later" return } @@ -175,7 +170,7 @@ function ClearStartMenu { $defaultProfile = "C:\Users\default\AppData\Local\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState" # Create folder if it doesn't exist - if(-not(Test-Path $defaultProfile)) { + if (-not(Test-Path $defaultProfile)) { new-item $defaultProfile -ItemType Directory -Force | Out-Null Write-Output "Created LocalState folder for default user" } @@ -189,13 +184,13 @@ function ClearStartMenu { # Add parameter to script and write to file function AddParameter { - param( + param ( $parameterName, $message ) # Add key if it doesn't already exist - if(-not $global:PSBoundParameters.ContainsKey($parameterName)){ + if (-not $global:PSBoundParameters.ContainsKey($parameterName)) { $global:PSBoundParameters.Add($parameterName, $true) } @@ -215,7 +210,7 @@ function AddParameter { function PrintHeader { - param( + param ( $title ) @@ -229,7 +224,7 @@ function PrintHeader { function PrintFromFile { - param( + param ( $path ) @@ -346,7 +341,7 @@ if ((-not $PSBoundParameters.Count) -or $RunDefaults -or $RunWin11Defaults -or ( } } - # Only add this option for windows 10 users, if it doesn't already exist + # Only add this option for Windows 10 users, if it doesn't already exist if ((get-ciminstance -query "select caption from win32_operatingsystem where caption like '%Windows 10%'") -and (-not $PSBoundParameters.ContainsKey('Hide3dObjects'))) { $PSBoundParameters.Add('Hide3dObjects', $Hide3dObjects) } @@ -389,36 +384,16 @@ if ((-not $PSBoundParameters.Count) -or $RunDefaults -or $RunWin11Defaults -or ( AddParameter 'RemoveApps' 'Remove default selection of bloatware apps' } - # Show options for removing communication-related apps, only continue on valid input - Do { - Write-Output "" - Write-Host " Options:" -ForegroundColor Yellow - Write-Host " (n) Don't remove communication-related apps" -ForegroundColor Yellow - Write-Host " (1) Remove Mail, Calender, People and Outlook for Windows apps" -ForegroundColor Yellow - Write-Host " (2) Only remove Mail, Calender and People apps" -ForegroundColor Yellow - Write-Host " (3) Only remove Outlook for Windows app" -ForegroundColor Yellow - $RemoveCommAppInput = Read-Host " Remove communication-related apps? (n/1/2/3)" - } - while ($RemoveCommAppInput -ne 'n' -and $RemoveCommAppInput -ne '0' -and $RemoveCommAppInput -ne '1' -and $RemoveCommAppInput -ne '2' -and $RemoveCommAppInput -ne '3') + Write-Output "" - # Select correct option based on user input - switch ($RemoveCommAppInput) { - '1' { - AddParameter 'RemoveCommApps' 'Remove the Mail, Calender, and People apps' - AddParameter 'RemoveW11Outlook' 'Remove the new Outlook for Windows app' - } - '2' { - AddParameter 'RemoveCommApps' 'Remove the Mail, Calender, and People apps' - } - '3' { - AddParameter 'RemoveW11Outlook' 'Remove the new Outlook for Windows app' - } + if ($( Read-Host -Prompt " Remove the Mail, Calender and People apps? (y/n)" ) -eq 'y') { + AddParameter 'RemoveCommApps' 'Remove the Mail, Calender and People apps' } Write-Output "" - if ($( Read-Host -Prompt " Remove developer-related apps such as Remote Desktop, DevHome and Power Automate? (y/n)" ) -eq 'y') { - AddParameter 'RemoveDevApps' 'Remove developer-related apps' + if ($( Read-Host -Prompt " Remove the new Outlook for Windows app? (y/n)" ) -eq 'y') { + AddParameter 'RemoveW11Outlook' 'Remove the new Outlook for Windows app' } Write-Output "" @@ -426,10 +401,16 @@ if ((-not $PSBoundParameters.Count) -or $RunDefaults -or $RunWin11Defaults -or ( if ($( Read-Host -Prompt " Remove gaming-related apps such as the Xbox App and Xbox Gamebar? (y/n)" ) -eq 'y') { AddParameter 'RemoveGamingApps' 'Remove the Xbox App and Xbox Gamebar' } + + Write-Output "" + + if ($( Read-Host -Prompt " Remove developer-related apps such as Remote Desktop, DevHome and Power Automate? (y/n)" ) -eq 'y') { + AddParameter 'RemoveDevApps' 'Remove developer-related apps' + } } } - # Only show this option for windows 11 users running build 22621 or later + # Only show this option for Windows 11 users running build 22621 or later if ($WinVersion -ge 22621){ Write-Output "" @@ -446,18 +427,18 @@ if ((-not $PSBoundParameters.Count) -or $RunDefaults -or $RunWin11Defaults -or ( Write-Output "" - if ($( Read-Host -Prompt "Disable bing search, bing AI & cortana in windows search? (y/n)" ) -eq 'y') { - AddParameter 'DisableBing' 'Disable bing search, bing AI & cortana in windows search' + if ($( Read-Host -Prompt "Disable bing search, bing AI & cortana in Windows search? (y/n)" ) -eq 'y') { + AddParameter 'DisableBing' 'Disable bing search, bing AI & cortana in Windows search' } Write-Output "" if ($( Read-Host -Prompt "Disable tips, tricks, suggestions and ads in start, settings, notifications, explorer and lockscreen? (y/n)" ) -eq 'y') { - AddParameter 'DisableSuggestions' 'Disable tips, tricks, suggestions and ads in start, settings, notifications and windows explorer' + AddParameter 'DisableSuggestions' 'Disable tips, tricks, suggestions and ads in start, settings, notifications and Windows explorer' AddParameter 'DisableLockscreenTips' 'Disable tips & tricks on the lockscreen' } - # Only show this option for windows 11 users running build 22621 or later + # Only show this option for Windows 11 users running build 22621 or later if ($WinVersion -ge 22621){ Write-Output "" @@ -466,7 +447,7 @@ if ((-not $PSBoundParameters.Count) -or $RunDefaults -or $RunWin11Defaults -or ( } } - # Only show this option for windows 11 users running build 22000 or later + # Only show this option for Windows 11 users running build 22000 or later if ($WinVersion -ge 22000){ Write-Output "" @@ -478,7 +459,7 @@ if ((-not $PSBoundParameters.Count) -or $RunDefaults -or $RunWin11Defaults -or ( Write-Output "" if ($( Read-Host -Prompt "Do you want to make any changes to the taskbar and related services? (y/n)" ) -eq 'y') { - # Only show these specific options for windows 11 users running build 22000 or later + # Only show these specific options for Windows 11 users running build 22000 or later if ($WinVersion -ge 22000){ Write-Output "" @@ -528,7 +509,7 @@ if ((-not $PSBoundParameters.Count) -or $RunDefaults -or $RunWin11Defaults -or ( AddParameter 'DisableWidgets' 'Disable the widget service & hide the widget (news and interests) icon from the taskbar' } - # Only show this options for windows users running build 22621 or earlier + # Only show this options for Windows users running build 22621 or earlier if ($WinVersion -le 22621){ Write-Output "" @@ -540,7 +521,7 @@ if ((-not $PSBoundParameters.Count) -or $RunDefaults -or $RunWin11Defaults -or ( Write-Output "" - if ($( Read-Host -Prompt "Do you want to make any changes to windows explorer? (y/n)" ) -eq 'y') { + if ($( Read-Host -Prompt "Do you want to make any changes to Windows explorer? (y/n)" ) -eq 'y') { Write-Output "" if ($( Read-Host -Prompt " Show hidden files, folders and drives? (y/n)" ) -eq 'y') { @@ -555,37 +536,37 @@ if ((-not $PSBoundParameters.Count) -or $RunDefaults -or $RunWin11Defaults -or ( Write-Output "" - if ($( Read-Host -Prompt " Hide duplicate removable drive entries from the windows explorer sidepane so they only show under This PC? (y/n)" ) -eq 'y') { - AddParameter 'HideDupliDrive' 'Hide duplicate removable drive entries from the windows explorer navigation pane' + if ($( Read-Host -Prompt " Hide duplicate removable drive entries from the Windows explorer sidepane so they only show under This PC? (y/n)" ) -eq 'y') { + AddParameter 'HideDupliDrive' 'Hide duplicate removable drive entries from the Windows explorer navigation pane' } - # Only show option for disabling these specific folders for windows 10 users + # Only show option for disabling these specific folders for Windows 10 users if (get-ciminstance -query "select caption from win32_operatingsystem where caption like '%Windows 10%'"){ Write-Output "" - if ($( Read-Host -Prompt "Do you want to hide any folders from the windows explorer sidepane? (y/n)" ) -eq 'y') { + if ($( Read-Host -Prompt "Do you want to hide any folders from the Windows explorer sidepane? (y/n)" ) -eq 'y') { Write-Output "" - if ($( Read-Host -Prompt " Hide the onedrive folder from the windows explorer sidepane? (y/n)" ) -eq 'y') { - AddParameter 'HideOnedrive' 'Hide the onedrive folder in the windows explorer sidepanel' + if ($( Read-Host -Prompt " Hide the onedrive folder from the Windows explorer sidepane? (y/n)" ) -eq 'y') { + AddParameter 'HideOnedrive' 'Hide the onedrive folder in the Windows explorer sidepanel' } Write-Output "" - if ($( Read-Host -Prompt " Hide the 3D objects folder from the windows explorer sidepane? (y/n)" ) -eq 'y') { - AddParameter 'Hide3dObjects' "Hide the 3D objects folder under 'This pc' in windows explorer" + if ($( Read-Host -Prompt " Hide the 3D objects folder from the Windows explorer sidepane? (y/n)" ) -eq 'y') { + AddParameter 'Hide3dObjects' "Hide the 3D objects folder under 'This pc' in Windows explorer" } Write-Output "" - if ($( Read-Host -Prompt " Hide the music folder from the windows explorer sidepane? (y/n)" ) -eq 'y') { - AddParameter 'HideMusic' "Hide the music folder under 'This pc' in windows explorer" + if ($( Read-Host -Prompt " Hide the music folder from the Windows explorer sidepane? (y/n)" ) -eq 'y') { + AddParameter 'HideMusic' "Hide the music folder under 'This pc' in Windows explorer" } } } } - # Only show option for disabling context menu items for windows 10 users + # Only show option for disabling context menu items for Windows 10 users if (get-ciminstance -query "select caption from win32_operatingsystem where caption like '%Windows 10%'"){ Write-Output "" @@ -647,7 +628,7 @@ else { # Execute all selected/provided parameters switch ($PSBoundParameters.Keys) { 'RemoveApps' { - RemoveApps "$PSScriptRoot/Appslist.txt" "> Removing pre-installed windows bloatware..." + RemoveApps "$PSScriptRoot/Appslist.txt" "> Removing pre-installed Windows bloatware..." continue } 'RemoveCommApps' { @@ -697,7 +678,7 @@ else { continue } {$_ -in "DisableBingSearches", "DisableBing"} { - RegImport "> Disabling bing search, bing AI & cortana in windows search..." $PSScriptRoot\Regfiles\Disable_Bing_Cortana_In_Search.reg + RegImport "> Disabling bing search, bing AI & cortana in Windows search..." $PSScriptRoot\Regfiles\Disable_Bing_Cortana_In_Search.reg continue } {$_ -in "DisableLockscrTips", "DisableLockscreenTips"} { @@ -757,19 +738,19 @@ else { continue } 'HideDupliDrive' { - RegImport "> Hiding duplicate removable drive entries from the windows explorer navigation pane..." $PSScriptRoot\Regfiles\Hide_duplicate_removable_drives_from_navigation_pane_of_File_Explorer.reg + RegImport "> Hiding duplicate removable drive entries from the Windows explorer navigation pane..." $PSScriptRoot\Regfiles\Hide_duplicate_removable_drives_from_navigation_pane_of_File_Explorer.reg continue } {$_ -in "HideOnedrive", "DisableOnedrive"} { - RegImport "> Hiding the onedrive folder from the windows explorer navigation pane..." $PSScriptRoot\Regfiles\Hide_Onedrive_Folder.reg + RegImport "> Hiding the onedrive folder from the Windows explorer navigation pane..." $PSScriptRoot\Regfiles\Hide_Onedrive_Folder.reg continue } {$_ -in "Hide3dObjects", "Disable3dObjects"} { - RegImport "> Hiding the 3D objects folder from the windows explorer navigation pane..." $PSScriptRoot\Regfiles\Hide_3D_Objects_Folder.reg + RegImport "> Hiding the 3D objects folder from the Windows explorer navigation pane..." $PSScriptRoot\Regfiles\Hide_3D_Objects_Folder.reg continue } {$_ -in "HideMusic", "DisableMusic"} { - RegImport "> Hiding the music folder from the windows explorer navigation pane..." $PSScriptRoot\Regfiles\Hide_Music_folder.reg + RegImport "> Hiding the music folder from the Windows explorer navigation pane..." $PSScriptRoot\Regfiles\Hide_Music_folder.reg continue } {$_ -in "HideIncludeInLibrary", "DisableIncludeInLibrary"} {