mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2025-11-17 02:56:17 +00:00
Added option to create System Restore Point
This commit is contained in:
1
Get.ps1
1
Get.ps1
@@ -3,6 +3,7 @@ param (
|
|||||||
[switch]$Verbose,
|
[switch]$Verbose,
|
||||||
[switch]$Sysprep,
|
[switch]$Sysprep,
|
||||||
[string]$User,
|
[string]$User,
|
||||||
|
[switch]$CreateRestorePoint,
|
||||||
[switch]$RunAppsListGenerator, [switch]$RunAppConfigurator,
|
[switch]$RunAppsListGenerator, [switch]$RunAppConfigurator,
|
||||||
[switch]$RunDefaults, [switch]$RunWin11Defaults,
|
[switch]$RunDefaults, [switch]$RunWin11Defaults,
|
||||||
[switch]$RunSavedSettings,
|
[switch]$RunSavedSettings,
|
||||||
|
|||||||
@@ -317,11 +317,11 @@ The quick and advanced usage methods support switch parameters. A table of all t
|
|||||||
|
|
||||||
| Parameter | Description |
|
| Parameter | Description |
|
||||||
| :-------: | ----------- |
|
| :-------: | ----------- |
|
||||||
|
| -CreateRestorePoint | Create a system restore point before making any changes. Unless a restore point was already created in the last 24 hours. |
|
||||||
| -Silent | Suppresses all interactive prompts, so the script will run without requiring any user input. |
|
| -Silent | Suppresses all interactive prompts, so the script will run without requiring any user input. |
|
||||||
| -Sysprep | Run the script in Sysprep mode. All changes will be applied to the Windows default user profile and will only affect new user accounts. |
|
| -Sysprep | Run the script in Sysprep mode. All changes will be applied to the Windows default user profile and will only affect new user accounts. |
|
||||||
| -User `<USERNAME>` | Run the script for the specified user, instead of the currently logged in user. This user must have logged on atleast once, and cannot be logged in at the time the script is run. |
|
| -User `<USERNAME>` | Run the script for the specified user, instead of the currently logged in user. This user must have logged on atleast once, and cannot be logged in at the time the script is run. |
|
||||||
| -RunDefaults | Run the script with the default settings. |
|
| -RunDefaults | Run the script with the default settings. |
|
||||||
| -DisableFastStartup | Disables Fast Start-up to ensure a full shutdown. |
|
|
||||||
| -RunSavedSettings | Run the script with the saved custom settings from last time. These settings are saved to and read from the `SavedSettings` file in the root folder of the script. |
|
| -RunSavedSettings | Run the script with the saved custom settings from last time. These settings are saved to and read from the `SavedSettings` file in the root folder of the script. |
|
||||||
| -RemoveApps | Remove the default selection of bloatware apps. |
|
| -RemoveApps | Remove the default selection of bloatware apps. |
|
||||||
| -RemoveAppsCustom | Remove all apps specified in the 'CustomAppsList' file. IMPORTANT: You can generate your custom list by running the script with the `-RunAppsListGenerator` parameter. No apps will be removed if this file does not exist. |
|
| -RemoveAppsCustom | Remove all apps specified in the 'CustomAppsList' file. IMPORTANT: You can generate your custom list by running the script with the `-RunAppsListGenerator` parameter. No apps will be removed if this file does not exist. |
|
||||||
@@ -344,6 +344,7 @@ The quick and advanced usage methods support switch parameters. A table of all t
|
|||||||
| -RevertContextMenu | Restore the old Windows 10 style context menu. (Windows 11 only) |
|
| -RevertContextMenu | Restore the old Windows 10 style context menu. (Windows 11 only) |
|
||||||
| -DisableMouseAcceleration | Turn off Enhance Pointer Precision, also known as mouse acceleration. Requires reboot to apply. |
|
| -DisableMouseAcceleration | Turn off Enhance Pointer Precision, also known as mouse acceleration. Requires reboot to apply. |
|
||||||
| -DisableStickyKeys | Disable the Sticky Keys keyboard shortcut. |
|
| -DisableStickyKeys | Disable the Sticky Keys keyboard shortcut. |
|
||||||
|
| -DisableFastStartup | Disables Fast Start-up to ensure a full shutdown. |
|
||||||
| -ShowHiddenFolders | Show hidden files, folders and drives. |
|
| -ShowHiddenFolders | Show hidden files, folders and drives. |
|
||||||
| -ShowKnownFileExt | Show file extensions for known file types. |
|
| -ShowKnownFileExt | Show file extensions for known file types. |
|
||||||
| -HideDupliDrive | Hide duplicate removable drive entries from the File Explorer navigation pane, so only the entry under 'This PC' remains. |
|
| -HideDupliDrive | Hide duplicate removable drive entries from the File Explorer navigation pane, so only the entry under 'This PC' remains. |
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ param (
|
|||||||
[switch]$Silent,
|
[switch]$Silent,
|
||||||
[switch]$Sysprep,
|
[switch]$Sysprep,
|
||||||
[string]$User,
|
[string]$User,
|
||||||
|
[switch]$CreateRestorePoint,
|
||||||
[switch]$RunAppsListGenerator, [switch]$RunAppConfigurator,
|
[switch]$RunAppsListGenerator, [switch]$RunAppConfigurator,
|
||||||
[switch]$RunDefaults, [switch]$RunWin11Defaults,
|
[switch]$RunDefaults, [switch]$RunWin11Defaults,
|
||||||
[switch]$RunSavedSettings,
|
[switch]$RunSavedSettings,
|
||||||
@@ -741,12 +742,42 @@ function GetUserName {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function CreateSystemRestorePoint {
|
||||||
|
Write-Output "> Creating system restore point..."
|
||||||
|
|
||||||
|
# Find existing restore points that are less than 24 hours old
|
||||||
|
try {
|
||||||
|
$recentRestorePoints = Get-ComputerRestorePoint | Where-Object { (Get-Date) - [System.Management.ManagementDateTimeConverter]::ToDateTime($_.CreationTime) -le (New-TimeSpan -Hours 24) }
|
||||||
|
} catch {
|
||||||
|
Write-Host "Error: Unable to retrieve existing restore points: $_" -ForegroundColor Red
|
||||||
|
Write-Output ""
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($recentRestorePoints.Count -eq 0) {
|
||||||
|
Checkpoint-Computer -Description "Restore point created by Win11Debloat" -RestorePointType "MODIFY_SETTINGS"
|
||||||
|
Write-Output "System restore point created successfully"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "A recent restore point already exists, no new restore point was created." -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Output ""
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function DisplayCustomModeOptions {
|
function DisplayCustomModeOptions {
|
||||||
# Get current Windows build version to compare against features
|
# Get current Windows build version to compare against features
|
||||||
$WinVersion = Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' CurrentBuild
|
$WinVersion = Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' CurrentBuild
|
||||||
|
|
||||||
PrintHeader 'Custom Mode'
|
PrintHeader 'Custom Mode'
|
||||||
|
|
||||||
|
if ($( Read-Host -Prompt "Do you wish to create a system restore point? (y/n)" ) -eq 'y') {
|
||||||
|
AddParameter 'CreateRestorePoint' 'Create a system restore point'
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Output ""
|
||||||
|
|
||||||
# Show options for removing apps, only continue on valid input
|
# Show options for removing apps, only continue on valid input
|
||||||
Do {
|
Do {
|
||||||
Write-Host "Options:" -ForegroundColor Yellow
|
Write-Host "Options:" -ForegroundColor Yellow
|
||||||
@@ -1131,7 +1162,7 @@ $WinVersion = Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\Current
|
|||||||
|
|
||||||
$global:Params = $PSBoundParameters
|
$global:Params = $PSBoundParameters
|
||||||
$global:FirstSelection = $true
|
$global:FirstSelection = $true
|
||||||
$SPParams = 'WhatIf', 'Confirm', 'Verbose', 'Silent', 'Sysprep', 'Debug', 'User'
|
$SPParams = 'WhatIf', 'Confirm', 'Verbose', 'Silent', 'Sysprep', 'Debug', 'User', 'CreateRestorePoint'
|
||||||
$SPParamCount = 0
|
$SPParamCount = 0
|
||||||
|
|
||||||
# Count how many SPParams exist within Params
|
# Count how many SPParams exist within Params
|
||||||
@@ -1274,7 +1305,7 @@ if ((-not $global:Params.Count) -or $RunDefaults -or $RunWin11Defaults -or $RunS
|
|||||||
Read-Host | Out-Null
|
Read-Host | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
$DefaultParameterNames = 'RemoveApps','DisableTelemetry','DisableBing','DisableLockscreenTips','DisableSuggestions','ShowKnownFileExt','DisableWidgets','HideChat','DisableCopilot','DisableFastStartup'
|
$DefaultParameterNames = 'CreateRestorePoint','RemoveApps','DisableTelemetry','DisableBing','DisableLockscreenTips','DisableSuggestions','ShowKnownFileExt','DisableWidgets','HideChat','DisableCopilot','DisableFastStartup'
|
||||||
|
|
||||||
PrintHeader 'Default Mode'
|
PrintHeader 'Default Mode'
|
||||||
|
|
||||||
@@ -1381,6 +1412,10 @@ if ($SPParamCount -eq $global:Params.Keys.Count) {
|
|||||||
else {
|
else {
|
||||||
# Execute all selected/provided parameters
|
# Execute all selected/provided parameters
|
||||||
switch ($global:Params.Keys) {
|
switch ($global:Params.Keys) {
|
||||||
|
'CreateRestorePoint' {
|
||||||
|
CreateSystemRestorePoint
|
||||||
|
continue
|
||||||
|
}
|
||||||
'RemoveApps' {
|
'RemoveApps' {
|
||||||
$appsList = ReadAppslistFromFile "$PSScriptRoot/Appslist.txt"
|
$appsList = ReadAppslistFromFile "$PSScriptRoot/Appslist.txt"
|
||||||
Write-Output "> Removing default selection of $($appsList.Count) apps..."
|
Write-Output "> Removing default selection of $($appsList.Count) apps..."
|
||||||
|
|||||||
Reference in New Issue
Block a user