Files
powershell-script/configwinpc.ps1
2025-10-18 16:09:11 +02:00

777 lines
33 KiB
PowerShell

# https://github.com/andrew-s-taylor/public/blob/main/De-Bloat/RemoveBloat.ps1
# https://github.com/marlock9/edge-debloat/blob/main/edge-debloat.reg
# https://github.com/Raphire/Win11Debloat/tree/master/Regfiles
clear-Host
# Open PowerShell as administrator
if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
exit
}
Write-Host ""
Write-Host -ForegroundColor Yellow "
######################################################
# #
# #
# SCRIPT FOR CONFIGURING AND DEBLOATING WINDOWS 11 #
# #
# by dado #
######################################################
"
# Sleep for 2 seconds
Start-Sleep -Seconds 2
##########################################################################################
# #
# Taskbar #
# #
##########################################################################################
# Taskbar Adjustment
Write-Host -ForegroundColor Yellow ">>> Manage Taskbar <<<"
Write-Host ""
# Define registry paths for taskbar settings
$RegistryPaths = @(
"HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced",
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced",
"HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search",
"HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer",
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer"
)
# Loop through each registry path to check if it exists
foreach ($path in $RegistryPaths) {
if (-not (Test-Path $path)) {
New-Item -Path $path -Force | Out-Null
}
}
# Set left align
Write-Host -ForegroundColor DarkGray ">>> Set left align <<<"
foreach ($path in $RegistryPaths[0..1]) {
New-ItemProperty -Path $path -Name "TaskbarAl" -Value 0 -Type DWORD -Force | Out-Null
}
# Show smaller taskbar button
Write-Host -ForegroundColor DarkGray ">>> Show smaller taskbar button <<<"
foreach ($path in $RegistryPaths[0..1]) {
New-ItemProperty -Path $path -Name "TaskbarSmallIcons" -Value 1 -Type DWORD -Force | Out-Null
}
# Hide TaskView button
Write-Host -ForegroundColor DarkGray ">>> Hide TaskView button <<<"
foreach ($path in $RegistryPaths[0..1]) {
Set-ItemProperty -Path $path -Name "ShowTaskViewButton" -Value 0 -Type DWORD -Force | Out-Null
}
# Remove Chat from the Taskbar
Write-Host -ForegroundColor DarkGray ">>> Removes Chat from the Taskbar <<<"
foreach ($path in $RegistryPaths[0..1]) {
New-ItemProperty -Path $path -Name "TaskbarMn" -Value 0 -Type DWORD -Force | Out-Null
}
# Disable widgets in the taskbar
Write-Host -ForegroundColor DarkGray ">>> Disable widgets in the taskbar <<<"
Set-ItemProperty -Path $RegistryPaths[0] -Name "TaskbarWidgetsEnabled" -Value 0 | Out-Null
Set-ItemProperty -Path $RegistryPaths[1] -Name "TaskbarWidgetsEnabled" -Value 0 | Out-Null
# Hide search
Write-Host -ForegroundColor DarkGray ">>> Hide search <<<"
Set-ItemProperty -Path $RegistryPaths[2] -Name "SearchBoxTaskbarMode" -Value 0 -Type DWORD -Force | Out-Null
# Disable the 'Windows + W' keyboard shortcut to open widgets
Write-Host -ForegroundColor DarkGray ">>> Disable the 'Windows + W' keyboard shortcut to open widgets <<<"
Set-ItemProperty -Path $RegistryPaths[3] -Name "ShowWindowsW" -Value 0 | Out-Null
Set-ItemProperty -Path $RegistryPaths[4] -Name "ShowWindowsW" -Value 0 | Out-Null
# Disable the widget service
Write-Host -ForegroundColor DarkGray ">>> Disable widget service <<<"
$widgetPaths = @(
"HKLM:\SOFTWARE\Microsoft\PolicyManager\default\NewsAndInterests",
"HKLM:\SOFTWARE\Policies\Microsoft\Dsh"
)
foreach ($path in $widgetPaths) {
if (-not (Test-Path $path)) {
New-Item -Path $path -Force | Out-Null
}
Set-ItemProperty -Path $path -Name "AllowNewsAndInterests" -Value 0 -Type DWORD -Force | Out-Null
}
####################################################################################################################################
# Enable End Task
Write-Host -ForegroundColor DarkGray ">>> Enable End Task <<<"
$endTaskPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
# Create the path if it doesn't exist
if (-not (Test-Path $endTaskPath)) {
New-Item -Path $endTaskPath -Force | Out-Null
}
Set-ItemProperty -Path $endTaskPath -Name "TaskbarEndTask" -Value 1 -Type DWORD -Force | Out-Null
####################################################################################################################################
# Disabling 'Recommended' section
Write-Host -ForegroundColor DarkGray ">>> Hide 'Recommended' section <<<"
$explorerPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer"
$startPath = "HKLM:\SOFTWARE\Microsoft\PolicyManager\current\device\Start"
$educationPath = "HKLM:\SOFTWARE\Microsoft\PolicyManager\current\device\Education"
# Create the Explorer path if it doesn't exist
if (-not (Test-Path $explorerPath)) {
New-Item -Path $explorerPath -Force | Out-Null
}
Set-ItemProperty -Path $explorerPath -Name "HideRecommendedSection" -Value 1 -Type DWORD -Force | Out-Null
# Create the Start path if it doesn't exist
if (-not (Test-Path $startPath)) {
New-Item -Path $startPath -Force | Out-Null
}
Set-ItemProperty -Path $startPath -Name "HideRecommendedSection" -Value 1 -Type DWORD -Force | Out-Null
# Create the Education path if it doesn't exist
if (-not (Test-Path $educationPath)) {
New-Item -Path $educationPath -Force | Out-Null
}
Set-ItemProperty -Path $educationPath -Name "IsEducationEnvironment" -Value 1 -Type DWORD -Force | Out-Null
Write-Host ""
####################################################################################################################################
# Turn off web results in the Start menu
Write-Host -ForegroundColor Yellow ">>> Turn off web results in the Start menu <<<"
# Set the registry paths
$RegistryPaths = @(
"HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Search",
"HKCU:SOFTWARE\Policies\Microsoft\Windows\Explorer"
)
$Properties = @{
"SearchboxTaskbarMode" = 0
"BingSearchEnabled" = 0
"DisableSearchBoxSuggestions" = 1
}
# Iterate over each registry path
foreach ($RegistryPath in $RegistryPaths) {
# Create the key if it does not exist
if (-NOT (Test-Path $RegistryPath)) {
New-Item -Path $RegistryPath -Force | Out-Null
}
foreach ($Name in $Properties.Keys) {
$Value = $Properties[$Name]
New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -Type DWORD -Force | Out-Null
}
}
Write-Host ""
##########################################################################################
# #
# Explorer #
# #
##########################################################################################
Write-Host -ForegroundColor Yellow ">>> Configure File Explorer <<<"
Write-Host ""
Write-Host -ForegroundColor DarkGray ">>> Open 'This PC' instead of 'Quick Access' <<<"
Write-Host -ForegroundColor DarkGray ">>> Enable Compact View <<<"
Write-Host -ForegroundColor DarkGray ">>> Show file extensions <<<"
# Set the registry paths for both HKLM and HKCU
$RegistryPaths = @(
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced",
"HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
)
# Create a hashtable to store the property names and their corresponding values
$ExplorerProperties = @{
"LaunchTo" = 1
"UseCompactMode" = 1
"HideFileExt" = 0
}
foreach ($RegistryPath in $RegistryPaths) {
if (-NOT (Test-Path $RegistryPath)) {
New-Item -Path $RegistryPath -Force | Out-Null
}
foreach ($Name in $ExplorerProperties.Keys) {
$Value = $ExplorerProperties[$Name]
New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -Type DWORD -Force | Out-Null
}
}
####################################################################################################################################
# Disable Group By Folder in Windows Explorer
Write-Host -ForegroundColor DarkGray ">>> Disabling Group By Folder feature <<<"
$groupByPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
# Create the path if it doesn't exist
if (-not (Test-Path $groupByPath)) {
New-Item -Path $groupByPath -Force | Out-Null
}
# Set the registry value to disable auto grouping
Set-ItemProperty -Path $groupByPath -Name "UseAutoGrouping" -Value 0 -Type DWORD -Force | Out-Null
####################################################################################################################################
# Enable Dark Mode in Windows
Write-Host -ForegroundColor DarkGray ">>> Enable Dark Mode <<<"
$darkModePath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"
# Create the path if it doesn't exist
if (-not (Test-Path $darkModePath)) {
New-Item -Path $darkModePath -Force | Out-Null
}
# Set the registry values to enable dark mode
Set-ItemProperty -Path $darkModePath -Name "AppsUseLightTheme" -Value 0 -Type DWORD -Force | Out-Null
Set-ItemProperty -Path $darkModePath -Name "SystemUsesLightTheme" -Value 0 -Type DWORD -Force | Out-Null
Write-Host ""
##########################################################################################
# #
# Spotlight #
# #
##########################################################################################
Write-Host -ForegroundColor Yellow ">>> Disable Spotlight <<<"
Write-Host ""
# Define registry paths for Windows Spotlight settings
$RegistryPaths = @(
"HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager",
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager",
"HKCU:\SOFTWARE\Policies\Microsoft\Windows\CloudContent",
"HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
)
# Define properties for lockscreen
$LockScreenProperties = @{
"RotatingLockScreenOverlayEnabled" = 0
"RotatingLockScreenEnabled" = 0
}
# Define properties for background
$BackgroundProperties = @{
"DisableSpotlightCollectionOnDesktop" = 1
"DisableWindowsSpotlightFeatures" = 1
}
# Disable Windows Spotlight on lockscreen
Write-Host -ForegroundColor DarkGray ">>> Disabling Windows Spotlight on lockscreen <<<"
foreach ($spotlight in $RegistryPaths[0..1]) {
if (Test-Path $spotlight) {
foreach ($Name in $LockScreenProperties.Keys) {
$Value = $LockScreenProperties[$Name]
Set-ItemProperty -Path $spotlight -Name $Name -Value $Value -Force | Out-Null
}
}
}
# Disable Windows Spotlight on background
Write-Host -ForegroundColor DarkGray ">>> Disabling Windows Spotlight on background <<<"
foreach ($spotlight in $RegistryPaths[2..3]) {
if (Test-Path $spotlight) {
foreach ($Name in $BackgroundProperties.Keys) {
$Value = $BackgroundProperties[$Name]
Set-ItemProperty -Path $spotlight -Name $Name -Value $Value -Force | Out-Null
}
}
}
Write-Host ""
##########################################################################################
# #
# Telemetry #
# #
##########################################################################################
# Configure Windows telemetry and activity tracking settings
Write-Host -ForegroundColor Yellow ">>> Disable some telemetry <<<"
$registryPaths = @(
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection",
"HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced",
"HKLM:\SOFTWARE\Policies\Microsoft\Windows\System",
"HKCU:\SOFTWARE\Microsoft\Siuf\Rules"
)
$TelemetryProperties = @{
"AllowTelemetry" = 0
"PublishUserActivities" = 0
}
$ActivityTrackingProperties = @{
"Start_TrackProgs" = 0
"NumberOfSIUFInPeriod" = 0
"PeriodInNanoSeconds" = -1
}
# Disable telemetry settings
foreach ($path in $registryPaths[0..1]) {
if (-not (Test-Path $path)) {
New-Item -Path $path -Force | Out-Null
}
foreach ($Name in $TelemetryProperties.Keys) {
$Value = $TelemetryProperties[$Name]
Set-ItemProperty -Path $path -Name $Name -Value $Value -Type DWORD -Force | Out-Null
}
}
# Disable activity tracking settings
foreach ($path in $registryPaths[2..3]) {
if (-not (Test-Path $path)) {
New-Item -Path $path -Force | Out-Null
}
foreach ($Name in $ActivityTrackingProperties.Keys) {
$Value = $ActivityTrackingProperties[$Name]
Set-ItemProperty -Path $path -Name $Name -Value $Value -Type DWORD -Force | Out-Null
}
}
Write-Host ""
##########################################################################################
# #
# Suggestion #
# #
##########################################################################################
# Disable Windows notifications, suggestions, and ads
Write-Host -ForegroundColor DarkGray ">>> Turn off Welcome Experience, notifications, suggestions, and ads in Windows <<<"
# Define registry paths and values to modify
$registryEntries = @(
@{ Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = "SubscribedContent-310093Enabled"; Value = 0 },
@{ Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = "SubscribedContent-338388Enabled"; Value = 0 },
@{ Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = "SystemPaneSuggestionsEnabled"; Value = 0 },
@{ Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = "SubscribedContent-338389Enabled"; Value = 0 },
@{ Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = "SoftLandingEnabled"; Value = 0 },
@{ Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = "SubscribedContent-338393Enabled"; Value = 0 },
@{ Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = "SubscribedContent-353694Enabled"; Value = 0 },
@{ Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = "SubscribedContent-353696Enabled"; Value = 0 },
@{ Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = "SubscribedContent-353698Enabled"; Value = 0 },
@{ Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\SystemSettings\AccountNotifications"; Name = "EnableAccountNotifications"; Value = 0 },
@{ Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\UserProfileEngagement"; Name = "ScoobeSystemSettingEnabled"; Value = 0 },
@{ Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"; Name = "ShowSyncProviderNotifications"; Value = 0 },
@{ Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = "SilentInstalledAppsEnabled"; Value = 0 },
@{ Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.Suggested"; Name = "Enabled"; Value = 0 },
@{ Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Mobility"; Name = "OptedIn"; Value = 0 },
@{ Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"; Name = "Start_AccountNotifications"; Value = 0 }
)
# Loop through each registry entry and set the values
foreach ($entry in $registryEntries) {
# Create the path if it doesn't exist
if (-not (Test-Path $entry.Path)) {
New-Item -Path $entry.Path -Force | Out-Null
}
Set-ItemProperty -Path $entry.Path -Name $entry.Name -Value $entry.Value -Type DWORD -Force | Out-Null
}
##########################################################################################
# #
# Recall #
# #
##########################################################################################
Write-Host -ForegroundColor DarkGray ">>> Disable Recall <<<"
# Define registry paths for taskbar settings
$RegistryPaths = @(
"HKCU:\SOFTWARE\Policies\Microsoft\Windows\WindowsAI",
"HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsAI"
)
# Loop through each registry path to check if it exists
foreach ($path in $RegistryPaths) {
# Check if the path does not exist
if (-not (Test-Path $path)) {
New-Item -Path $path -Force | Out-Null # Create the registry path
}
}
# Disable AI data analysis
Write-Host -ForegroundColor DarkGray ">>> Disable AI data analysis <<<"
foreach ($path in $RegistryPaths[0..1]) {
New-ItemProperty -Path $path -Name "DisableAIDataAnalysis" -Value 1 -Type DWORD -Force | Out-Null
}
Set-ItemProperty -Path $RegistryPaths[1] -Name "AllowRecallEnablement" -Value 0 -Type DWORD -Force | Out-Null
# Turn off Recall snapshots
Write-Host -ForegroundColor DarkGray ">>> Turn off Recall snapshots <<<"
Set-ItemProperty -Path $RegistryPaths[1] -Name "TurnOffSavingSnapshots" -Value 1 -Type DWORD -Force | Out-Null
Write-Host ""
##########################################################################################
# #
# Lock Screen Notifications #
# #
##########################################################################################
Write-Host -ForegroundColor Yellow ">>> Disable Notifications on Lock Screen <<<"
# Set the registry paths for notifications settings
$RegistryPaths = @(
"HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings",
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings",
"HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\PushNotifications",
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\PushNotifications"
)
# Create a hashtable to store the property names and their corresponding values
$NotificationProperties = @{
"NOC_GLOBAL_SETTING_ALLOW_TOASTS_ABOVE_LOCK" = 0
"LockScreenToastEnabled" = 0
}
foreach ($RegistryPath in $RegistryPaths) {
if (-NOT (Test-Path $RegistryPath)) {
New-Item -Path $RegistryPath -Force | Out-Null
}
foreach ($Name in $NotificationProperties.Keys) {
$Value = $NotificationProperties[$Name]
New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -Type DWORD -Force | Out-Null
}
}
Write-Host ""
####################################################################################################################################
Write-Host -ForegroundColor Yellow ">>> Disable Lets finish setting up your device <<<"
$RegistryPaths = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
# Check if the path exists
if (-not (Test-Path $RegistryPaths)) {
# Create the path if it doesn't exist
New-Item -Path $RegistryPaths -Force | Out-Null
}
Set-ItemProperty -Path $RegistryPaths -Name "SubscribedContent-338389Enabled" -Value 0 -Force | Out-Null
Write-Host ""
##########################################################################################
# #
# Control Panel #
# #
##########################################################################################
Write-Host -ForegroundColor Yellow ">>> Change Control Panel View to 'Small icon'<<<"
$RegistryPaths = @(
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel",
"HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel"
)
# Create a hashtable to store the property names and their corresponding values
$ControlPanelProperties = @{
"AllItemsIconView" = 1
"StartupPage" = 1
}
foreach ($RegistryPath in $RegistryPaths) {
if (-NOT (Test-Path $RegistryPath)) {
New-Item -Path $RegistryPath -Force | Out-Null
}
foreach ($Name in $ControlPanelProperties.Keys) {
$Value = $ControlPanelProperties[$Name]
New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -Type DWORD -Force | Out-Null
}
}
Write-Host ""
##########################################################################################
# #
# Edge #
# #
##########################################################################################
Write-Host -ForegroundColor Yellow ">>> Disable Microsoft Edge First Run Welcome Page <<<"
# Set the registry paths
$RegistryPaths = @(
"HKLM:\SOFTWARE\Policies\Microsoft\Edge",
"HKCU:\SOFTWARE\Policies\Microsoft\Edge"
)
# https://gist.github.com/asheroto/e18500e7d206f3ae99f9bd0da0cf6bc6
$EdgeProperties = @{
"AlternateErrorPagesEnabled" = 0
"ComposeInlineEnabled" = 0
"CopilotCDPPageContext" = 0
"CopilotPageContext" = 0
"DefaultBrowserSettingsCampaignEnabled" = 0
"DiagnosticData" = 0
"EdgeCollectionsEnabled" = 0
"EdgeEntraCopilotPageContext" = 0
"EdgeHistoryAISearchEnabled" = 0
"EdgeShoppingAssistantEnabled" = 0
"GenAILocalFoundationalModelSettings" = 1
"HideFirstRunExperience" = 1
"HubsSidebarEnabled" = 0
"Microsoft365CopilotChatIconEnabled" = 0
"NewTabPageAllowedBackgroundTypes" = 3
"NewTabPageAppLauncherEnabled" = 0
"NewTabPageBingChatEnabled" = 0
"NewTabPageContentEnabled" = 0
"NewTabPageHideDefaultTopSites" = 1
"PersonalizationReportingEnabled" = 0
"PersonalizeTopSitesInCustomizeSidebarEnabled" = 0
"ShowAcrobatSubscriptionButton" = 0
"ShowMicrosoftRewards" = 0
"ShowRecommendationsEnabled" = 0
"TabServicesEnabled" = 0
"UserFeedbackAllowed" = 0
"VisualSearchEnabled" = 0
}
# Iterate over each registry path
foreach ($RegistryPath in $RegistryPaths) {
if (-NOT (Test-Path $RegistryPath)) {
New-Item -Path $RegistryPath -Force | Out-Null
}
foreach ($Name in $EdgeProperties.Keys) {
$Value = $EdgeProperties[$Name]
New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -Type DWORD -Force | Out-Null
}
}
Write-Host ""
##########################################################################################
# #
# Power Plan #
# #
##########################################################################################
Write-Host -ForegroundColor Yellow ">>> Power Plan <<<"
Write-Host ""
Write-Host -ForegroundColor DarkGray ">>> Activate High performance power plan <<<"
powercfg -setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
# Create ultimate powerscheme
powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61 | Out-Null
####################################################################################################################################
Write-Host -ForegroundColor DarkGray ">>> Setting the monitor timeout to 10 minutes <<<"
# AC power
powercfg -change -monitor-timeout-ac 10
powercfg -change -standby-timeout-ac 10
powercfg -change -hibernate-timeout-ac 0
powercfg -change -disk-timeout-ac 0
# On battery
powercfg -change -monitor-timeout-dc 10
powercfg -change -standby-timeout-dc 10
powercfg -change -hibernate-timeout-dc 0
powercfg -change -disk-timeout-dc 0
powercfg /hibernate off
####################################################################################################################################
# Set the power button behavior for AC power to "Shut down"
Write-Host -ForegroundColor DarkGray ">>> Setting the power button behavior to 'Shut down' <<<"
powercfg -setacvalueindex SCHEME_CURRENT SUB_BUTTONS PBUTTONACTION 3
powercfg -setdcvalueindex SCHEME_CURRENT SUB_BUTTONS PBUTTONACTION 3
# Set the sleep button behavior to "Do nothing"
Write-Host -ForegroundColor DarkGray ">>> Setting the sleep button behavior to 'Do nothing' <<<"
# Set the sleep button behavior for battery power to "Do nothing"
powercfg /SETACVALUEINDEX SCHEME_CURRENT SUB_BUTTONS SBUTTONACTION 0
powercfg /SETDCVALUEINDEX SCHEME_CURRENT SUB_BUTTONS SBUTTONACTION 0
####################################################################################################################################
# Disable Fast Startup
Write-Host -ForegroundColor DarkGray ">>> Disable fast startup <<<"
$RegistryPaths = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power"
# Check if the path exists
if (-not (Test-Path $RegistryPaths)) {
# Create the path if it doesn't exist
New-Item -Path $RegistryPaths -Force | Out-Null
}
Set-ItemProperty -Path $RegistryPaths -Name "HiberbootEnabled" -Value 0 -Force | Out-Null
####################################################################################################################################
Write-Host -ForegroundColor DarkGray ">>> Disable Energy-Efficient Ethernet <<<"
$adapter = Get-NetAdapter | Where-Object { $_.Name -eq "Ethernet" }
Disable-NetAdapterPowerManagement -Name $adapter.Name -NoRestart
Set-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Control\Class\{0}\{1}" -f "{4D36E972-E325-11CE-BFC1-08002BE10318}", $idNIC) -Name "PnPCapabilities" -Value "24" -Type DWORD -Force | Out-Null
Write-Host ""
##########################################################################################
# #
# Windows Update Setting #
# #
##########################################################################################
Write-Host -ForegroundColor Yellow ">>> Windows Update settings <<<"
Write-Host ""
Write-Host -ForegroundColor DarkGray ">>> Enable 'Get updates for other Microsoft products' <<<"
try {
$UpdateServiceManager = New-Object -ComObject "Microsoft.Update.ServiceManager"
$ServiceID = "7971f918-a847-4430-9279-4a52d1efe18d" # GUID for Microsoft Update
$UpdateServiceManager.AddService2($ServiceID, 7, "") | Out-Null
}
catch {
Write-Error -ForegroundColor Red "An error occurred while configuring Microsoft Update: $($_.Exception.Message)"
}
####################################################################################################################################
# Set "Do not restart if user is logged on"
Write-Host -ForegroundColor DarkGray ">>> Set 'Do not restart if user is logged on' <<<"
$WindowsUpdateRegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update"
if (!(Test-Path $WindowsUpdateRegistryPath)) {
New-Item -Path $WindowsUpdateRegistryPath -Force | Out-Null
}
Set-ItemProperty -Path $WindowsUpdateRegistryPath -Name "NoAutoRebootWithLoggedOnUsers" -Value 1 -Type DWORD | Out-Null
####################################################################################################################################
# Restart File Explorer to apply the changes
taskkill /f /im explorer.exe | Out-Null
start explorer.exe | Out-Null
Write-Host ""
##########################################################################################
# #
# Remove Bloatware #
# #
##########################################################################################
Write-Host -ForegroundColor Yellow ">>> Starting the process to remove unnecessary bloatware applications... <<<"
Write-Host ""
# Get the directory of the currently executing script
$scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Path
# bloatware.txt path
$appsToRemove = Get-Content (Join-Path $scriptDirectory "bloatware.txt")
# Remove the specified apps from the list
foreach ($app in $appsToRemove) {
try {
winget uninstall --name $app | Out-Null
# Check if the app was removed successfully
if ($LASTEXITCODE -eq 0) {
Write-Host "Removed: $app"
}
else {
Write-Host "Not found: $app"
}
} catch {
Write-Host -ForegroundColor Red "Error removing: $app. Details: $_"
}
}
####################################################################################################################################
# Disable Microsoft 365 Ads in Settings Home
$RegistryPaths = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
# Create the path if it doesn't exist
if (-not (Test-Path $RegistryPaths)) {
New-Item -Path $RegistryPaths -Force | Out-Null
}
# Set the registry value to disable ads
Set-ItemProperty -Path $RegistryPaths -Name "DisableConsumerAccountStateContent" -Value 1 -Type DWORD -Force | Out-Null
####################################################################################################################################
# Uninstall Microsoft Office
Write-Host ""
Write-Host -ForegroundColor Yellow ">>> Uninstall Microsoft Office <<<"
Start-Process "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" "https://aka.ms/SaRA-officeUninstallFromPC"
##########################################################################################
# #
# SOFTWARE #
# #
##########################################################################################
# https://winstall.app/ - Browse the winget repository
Write-Host ""
Write-Host -ForegroundColor Yellow ">>> Upgrade packages... <<<"
Write-Host ""
winget upgrade --all
Write-Host ""
Write-Host -ForegroundColor Yellow ">>> Install default SOFTWARE... <<<"
Write-Host ""
winget install --disable-interactivity SumatraPDF.SumatraPDF Microsoft.Edit Notepad++.Notepad++ 7zip.7zip Mozilla.Firefox Flameshot.Flameshot DuongDieuPhap.ImageGlass Microsoft.PowerToys --source winget
# Microsoft.PowerShell NodirTemirkhodjaev.FortFirewall voidtools.Everything Flow-Launcher.Flow-Launcher AutoHotkey.AutoHotkey Oracle.JavaRuntimeEnvironment Microsoft.VCRedist.2010.x64
####################################################################################################################################
#Write-Host -ForegroundColor DarkGray ">>> Copy 'Supremo' to Public Desktop <<<"
## Get the directory where the script is located
#$scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Path
## Define the path to the supremo executable
#$supremo_path = Join-Path $scriptDirectory "supremo.exe"
#
#if (Test-Path $supremo_path ) {
# Copy-Item -Path "$supremo_path" -Destination "C:\Users\Public\Desktop\supremo.exe"
#} else {
# Write-Host -ForegroundColor Red "Error: File '$supremo_path' does not exist."
#}
Write-Host ""
##########################################################################################
# #
# End #
# #
##########################################################################################
# Show the message
Write-Host -ForegroundColor Cyan ">>> Press any key to continue... <<<"
# Wait for a key press
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
Write-Host -ForegroundColor Red "Restart the system to apply the changes..."
Restart-Computer -Force