From 9a700afaedf0a9f960c9970be0bd02c819d02613 Mon Sep 17 00:00:00 2001 From: Jeffrey <9938813+Raphire@users.noreply.github.com> Date: Sun, 28 Jun 2026 22:53:27 +0200 Subject: [PATCH] Consolidate Get-Dev.ps1 into Get.ps1, add WhatIf support to Get.ps1 (#681) --- .github/CONTRIBUTING.md | 2 +- Scripts/Get-Dev.ps1 | 231 ---------------------------------------- Scripts/Get.ps1 | 24 +++-- 3 files changed, 16 insertions(+), 241 deletions(-) delete mode 100644 Scripts/Get-Dev.ps1 diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 770a274..070c47b 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -18,7 +18,7 @@ You can help us test the latest changes and additions to the script. If you enco You can launch the prerelease version of Win11Debloat by running this command: ```ps1 -& ([scriptblock]::Create((irm "https://debloat.raphi.re/dev"))) +& ([scriptblock]::Create((irm "https://debloat.raphi.re/"))) -Dev ``` # Contributing Code diff --git a/Scripts/Get-Dev.ps1 b/Scripts/Get-Dev.ps1 deleted file mode 100644 index b8a2e9c..0000000 --- a/Scripts/Get-Dev.ps1 +++ /dev/null @@ -1,231 +0,0 @@ -param ( - [switch]$CLI, - [switch]$Silent, - [switch]$Verbose, - [switch]$Sysprep, - [string]$LogPath, - [string]$User, - [switch]$NoRestartExplorer, - [switch]$CreateRestorePoint, - [switch]$RunDefaults, - [switch]$RunDefaultsLite, - [switch]$RunSavedSettings, - [string]$Config, - [string]$Apps, - [string]$AppRemovalTarget, - [switch]$RemoveApps, - [switch]$RemoveGamingApps, - [switch]$RemoveHPApps, - [switch]$ForceRemoveEdge, - [switch]$DisableDVR, - [switch]$DisableGameBarIntegration, - [switch]$EnableWindowsSandbox, - [switch]$EnableWindowsSubsystemForLinux, - [switch]$DisableTelemetry, - [switch]$DisableSearchHistory, - [switch]$DisableFastStartup, - [switch]$DisableBitlockerAutoEncryption, - [switch]$DisableModernStandbyNetworking, - [switch]$DisableStorageSense, - [switch]$DisableUpdateASAP, - [switch]$PreventUpdateAutoReboot, - [switch]$DisableDeliveryOptimization, - [switch]$DisableBing, - [switch]$DisableStoreSearchSuggestions, - [switch]$DisableDesktopSpotlight, - [switch]$DisableLockscreenTips, - [switch]$DisableSuggestions, - [switch]$DisableLocationServices, - [switch]$DisableFindMyDevice, - [switch]$DisableEdgeAds, - [switch]$DisableBraveBloat, - [switch]$DisableSettings365Ads, - [switch]$DisableSettingsHome, - [switch]$ShowHiddenFolders, - [switch]$ShowKnownFileExt, - [switch]$HideDupliDrive, - [switch]$EnableDarkMode, - [switch]$DisableTransparency, - [switch]$DisableAnimations, - [switch]$TaskbarAlignLeft, - [switch]$CombineTaskbarAlways, [switch]$CombineTaskbarWhenFull, [switch]$CombineTaskbarNever, - [switch]$CombineMMTaskbarAlways, [switch]$CombineMMTaskbarWhenFull, [switch]$CombineMMTaskbarNever, - [switch]$MMTaskbarModeAll, [switch]$MMTaskbarModeMainActive, [switch]$MMTaskbarModeActive, - [switch]$HideSearchTb, [switch]$ShowSearchIconTb, [switch]$ShowSearchLabelTb, [switch]$ShowSearchBoxTb, - [switch]$HideTaskview, - [switch]$DisableStartRecommended, - [switch]$DisableStartAllApps, [switch]$StartAllAppsCategory, [switch]$StartAllAppsGrid, [switch]$StartAllAppsList, - [switch]$DisableStartPhoneLink, - [switch]$DisableCopilot, - [switch]$DisableRecall, - [switch]$DisableClickToDo, - [switch]$DisableAISvcAutoStart, - [switch]$DisablePaintAI, - [switch]$DisableNotepadAI, - [switch]$DisableEdgeAI, - [switch]$DisableSearchHighlights, - [switch]$DisableWidgets, - [switch]$HideChat, - [switch]$EnableEndTask, - [switch]$EnableLastActiveClick, - [switch]$ClearStart, - [string]$ReplaceStart, - [switch]$ClearStartAllUsers, - [string]$ReplaceStartAllUsers, - [switch]$RevertContextMenu, - [switch]$DisableDragTray, - [switch]$DisableMouseAcceleration, - [switch]$DisableStickyKeys, - [switch]$DisableWindowSnapping, - [switch]$DisableSnapAssist, - [switch]$DisableSnapLayouts, - [switch]$HideTabsInAltTab, [switch]$Show3TabsInAltTab, [switch]$Show5TabsInAltTab, [switch]$Show20TabsInAltTab, - [switch]$HideHome, - [switch]$HideGallery, - [switch]$ExplorerToHome, - [switch]$ExplorerToThisPC, - [switch]$ExplorerToDownloads, - [switch]$ExplorerToOneDrive, - [switch]$AddFoldersToThisPC, - [switch]$HideOnedrive, - [switch]$Hide3dObjects, - [switch]$HideMusic, - [switch]$HideIncludeInLibrary, - [switch]$HideGiveAccessTo, - [switch]$HideShare, - [switch]$ShowDriveLettersFirst, - [switch]$ShowDriveLettersLast, - [switch]$ShowNetworkDriveLettersFirst, - [switch]$HideDriveLetters -) - -# Show error if current powershell environment does not have LanguageMode set to FullLanguage -if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage") { - Write-Host "Error: Win11Debloat is unable to run on your system. PowerShell execution is restricted by security policies" -ForegroundColor Red - Write-Output "" - Write-Output "Press enter to exit..." - Read-Host | Out-Null - Exit -} - -Clear-Host -Write-Output "-------------------------------------------------------------------------------------------" -Write-Output " Win11Debloat Script - Get Dev" -Write-Output "-------------------------------------------------------------------------------------------" - -$tempRootPath = $env:TEMP -$tempWorkPath = Join-Path $tempRootPath 'Win11Debloat' -$tempArchivePath = Join-Path $tempRootPath 'win11debloat.zip' - -Write-Output "> Downloading Win11Debloat for development..." - -# Download latest version of Win11Debloat from GitHub master branch as zip archive -try { - Invoke-RestMethod "https://github.com/Raphire/Win11Debloat/archive/refs/heads/master.zip" -OutFile $tempArchivePath -} -catch { - Write-Host "Error: Unable to fetch master branch from GitHub. Please check your internet connection and try again." -ForegroundColor Red - Write-Output "" - Write-Output "Press enter to exit..." - Read-Host | Out-Null - Exit -} - -# Remove old script folder if it exists, but keep configs, logs and backups -if (Test-Path $tempWorkPath) { - Write-Output "" - Write-Output "> Cleaning up old Win11Debloat folder..." - - Get-ChildItem -Path $tempWorkPath -Exclude Config,Logs,Backups | Remove-Item -Recurse -Force -} - -$configDir = Join-Path $tempWorkPath 'Config' -$backupDir = Join-Path $tempWorkPath 'ConfigOld' - -# Temporarily move existing config files if they exist to prevent them from being overwritten by the new script files, will be moved back after the new script is unpacked -if (Test-Path "$configDir") { - Write-Output "" - Write-Output "> Backing up existing config files..." - - New-Item -ItemType Directory -Path "$backupDir" -Force | Out-Null - - $filesToKeep = @( - 'LastUsedSettings.json' - ) - - Get-ChildItem -Path "$configDir" -Recurse | Where-Object { $_.Name -in $filesToKeep } | Move-Item -Destination "$backupDir" - - Remove-Item "$configDir" -Recurse -Force -} - -Write-Output "" -Write-Output "> Unpacking..." - -# Unzip archive to Win11Debloat folder -Expand-Archive $tempArchivePath $tempWorkPath - -# Remove archive -Remove-Item $tempArchivePath - -# Move files -Get-ChildItem -Path (Join-Path $tempWorkPath '*Win11Debloat-*') -Recurse | Move-Item -Destination $tempWorkPath - -# Add existing config files back to Config folder -if (Test-Path "$backupDir") { - if (-not (Test-Path "$configDir")) { - New-Item -ItemType Directory -Path "$configDir" -Force | Out-Null - } - - Write-Output "" - Write-Output "> Restoring existing config files..." - - Get-ChildItem -Path "$backupDir" -Recurse | Move-Item -Destination "$configDir" - Remove-Item "$backupDir" -Recurse -Force -} - -# Make list of arguments to pass on to the script -$arguments = $($PSBoundParameters.GetEnumerator() | ForEach-Object { - if ($_.Value -eq $true) { - "-$($_.Key)" - } - else { - "-$($_.Key) ""$($_.Value)""" - } -}) - -Write-Output "" -Write-Output "> Launching Win11Debloat..." - -# Minimize the powershell window when no parameters are provided -if ($arguments.Count -eq 0) { - $windowStyle = "Minimized" -} -else { - $windowStyle = "Normal" -} - -# Remove Powershell 7 modules from path to prevent module loading issues in the script -if ($PSVersionTable.PSVersion.Major -ge 7) { - $NewPSModulePath = $env:PSModulePath -split ';' | Where-Object -FilterScript { $_ -like '*WindowsPowerShell*' } - $env:PSModulePath = $NewPSModulePath -join ';' -} - -# Run Win11Debloat script with the provided arguments -$debloatScriptPath = Join-Path $tempWorkPath 'Win11Debloat.ps1' -$debloatProcess = Start-Process powershell.exe -WindowStyle $windowStyle -PassThru -ArgumentList "-executionpolicy bypass -File `"$debloatScriptPath`" $arguments" -Verb RunAs - -# Wait for the process to finish before continuing -if ($null -ne $debloatProcess) { - $debloatProcess.WaitForExit() -} - -# Remove all remaining script files, except for configs, logs and backups -if (Test-Path $tempWorkPath) { - Write-Output "" - Write-Output "> Cleaning up..." - - # Cleanup, remove Win11Debloat directory - Get-ChildItem -Path $tempWorkPath -Exclude Config,Logs,Backups | Remove-Item -Recurse -Force -} - -Write-Output "" diff --git a/Scripts/Get.ps1 b/Scripts/Get.ps1 index 012cb89..8827757 100644 --- a/Scripts/Get.ps1 +++ b/Scripts/Get.ps1 @@ -1,7 +1,9 @@ param ( + [switch]$Verbose, + [switch]$WhatIf, + [switch]$Dev, [switch]$CLI, [switch]$Silent, - [switch]$Verbose, [switch]$Sysprep, [string]$LogPath, [string]$User, @@ -110,7 +112,7 @@ if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage") { Clear-Host Write-Output "-------------------------------------------------------------------------------------------" -Write-Output " Win11Debloat Script - Get" +Write-Output " Win11Debloat Script" Write-Output "-------------------------------------------------------------------------------------------" $tempRootPath = $env:TEMP @@ -119,13 +121,17 @@ $tempArchivePath = Join-Path $tempRootPath 'win11debloat.zip' Write-Output "> Downloading Win11Debloat..." -# Download latest version of Win11Debloat from GitHub as zip archive +# Download Win11Debloat from GitHub as a zip archive. try { - $LatestReleaseUri = (Invoke-RestMethod https://api.github.com/repos/Raphire/Win11Debloat/releases/latest).zipball_url - Invoke-RestMethod $LatestReleaseUri -OutFile $tempArchivePath + if ($Dev) { + $sourceUri = "https://github.com/Raphire/Win11Debloat/archive/refs/heads/master.zip" + } else { + $sourceUri = (Invoke-RestMethod https://api.github.com/repos/Raphire/Win11Debloat/releases/latest).zipball_url + } + Invoke-RestMethod $sourceUri -OutFile $tempArchivePath } catch { - Write-Host "Error: Unable to fetch latest release from GitHub. Please check your internet connection and try again." -ForegroundColor Red + Write-Host "Error: Unable to fetch required files from GitHub. Please check your internet connection and try again." -ForegroundColor Red Write-Output "" Write-Output "Press enter to exit..." Read-Host | Out-Null @@ -135,7 +141,7 @@ catch { # Remove old script folder if it exists, but keep configs, logs and backups if (Test-Path $tempWorkPath) { Write-Output "" - Write-Output "> Cleaning up old Win11Debloat folder..." + Write-Output "> Cleaning up old script files..." Get-ChildItem -Path $tempWorkPath -Exclude Config,Logs,Backups | Remove-Item -Recurse -Force } @@ -184,8 +190,8 @@ if (Test-Path "$backupDir") { Remove-Item "$backupDir" -Recurse -Force } -# Make list of arguments to pass on to the script -$arguments = $($PSBoundParameters.GetEnumerator() | ForEach-Object { +# Make list of arguments to pass on to the script (exclude the -Dev switch, which only affects this launcher) +$arguments = $($PSBoundParameters.GetEnumerator() | Where-Object { $_.Key -ne 'Dev' } | ForEach-Object { if ($_.Value -eq $true) { "-$($_.Key)" }