# region Script Configuration $desiredPowerPlan = "Ultimate Performance" $installWingetPackages = @( "Git.Git", "Discord.Discord", "7zip.7zip", "RazerInc.RazerInstaller.Synapse4", "EpicGames.EpicGamesLauncher", "Valve.Steam", "ShareX.ShareX", "Guru3D.Afterburner", "Spotify.Spotify", "REALiX.HWiNFO", "JetBrains.Toolbox", "Rainmeter.Rainmeter", "Microsoft.PowerToys", "Brave.Brave", "GnuPG.Gpg4win", "Microsoft.VisualStudioCode", "Docker.DockerDesktop", "Logitech.GHUB" ) # endregion # region Script Execution # Set power plan - create Ultimate Performance Plan as an additional option if it doesn't exist [PowerPlan]::EnforceUltimatePerformancePlan() [PowerPlan]::EnforcePowerPlan($desiredPowerPlan) # Handle general windows settings and functionality [WindowsGeneral]::DisableWindowsWebSearch() [WindowsGeneral]::EnableAllTaskbarNotifications() [WindowsGeneral]::RemoveWindowsWidgets() [WindowsGeneral]::EnableDetailedContextExplorer() [WindowsGeneral]::DisableFileExplorerGallery() [WindowsGeneral]::DisableFileExplorerOneDrivePersonal() # Adjust cpu, graphics and network performance settings [Network]::DisableNetworkThrottling() # Disable HPET (High Precision Event Timer) due to varying levels of performance degredation for gaming use [CPU]::DisableHpet() # Configure TDR delay for rendering hangs | TDR == Timeout Detection and Recovery [Graphics]::DisableTdr() # Install desired applications and services via winget foreach ($packageId in $installWingetPackages){ $packageInstalled = [WindowsGeneral]::InstallWingetPackage($packageId) if ($packageInstalled) { Write-Host -ForegroundColor $displayColorSuccess "Succesfully installed/update package: $packageId" } else { Write-Host -ForegroundColor $displayColorFailure "Failed to install/update package: $packageId" } } # endregion # region Classes class ScriptHelpers { static [string] $ColorDefault = "Gray" static [string] $ColorSuccess = "Green" static [string] $ColorFailure = "Red" static [void] Print($message) { Write-Host -ForegroundColor "$([ScriptHelpers]::ColorDefault)" $message } static [void] PrintSuccess($message) { Write-Host -ForegroundColor "$([ScriptHelpers]::ColorSuccess)" $message } static [void] PrintError($message) { Write-Host -ForegroundColor "$([ScriptHelpers]::ColorFailure)" $message } } class WindowsGeneral { static [bool] DisableWindowsWebSearch(){ try { Set-ItemProperty -Path 'HKCU:\SOFTWARE\Policies\Microsoft\Windows' -Name 'DisableSearchBoxSuggestions' -Value '1' -Type Dword [ScriptHelpers]::PrintSuccess("Successfully disabled web search in windows search") return $true } catch { [ScriptHelpers]::PrintError("Failed to disable web search in windows search") return $false } } static [bool] EnableAllTaskbarNotifications(){ try { Set-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer' -Name 'EnableAutoTray' -Value '0' -Type Dword [ScriptHelpers]::PrintSuccess("Successfully enabled all taskbar notifications") return $true } catch { [ScriptHelpers]::PrintError("Failed to enable all taskbar notifications") return $false } } static [bool] EnableDetailedContextExplorer(){ try { $registryPathExplorerContext = "HKCU:\SOFTWARE\CLASSES\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" if (!(Test-Path $registryPathExplorerContext)) { New-Item -Path $registryPathExplorerContext -Force } [ScriptHelpers]::PrintSuccess("Successfully enabled detailed context menu in file explorer") return $true } catch { [ScriptHelpers]::PrintError("Failed to enable detailed context menu in file explorer") return $false } } static [bool] DisableFileExplorerGallery(){ try { Remove-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{e88865ea-0e1c-4e20-9aa6-edcd0212c87c}' [ScriptHelpers]::PrintSuccess("Successfully disabled the gallery display in file explorer") return $true } catch { [ScriptHelpers]::PrintError("Failed to disable the gallery display in file explorer") return $false } } static [bool] DisableFileExplorerOneDrivePersonal(){ try { Remove-Item -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{018D5C66-4533-4307-9B53-224DE2ED1FE6}' [ScriptHelpers]::PrintSuccess("Successfully disabled one drive personal in file explorer") return $true } catch { [ScriptHelpers]::PrintError("Failed to disable one drive personal in file explorer") return $false } } static [bool] InstallWinget(){ try { # Get the latest download url $URL = "https://api.github.com/repos/microsoft/winget-cli/releases/latest" $URL = (Invoke-WebRequest -Uri $URL).Content | ConvertFrom-Json | Select-Object -ExpandProperty "assets" | Where-Object "browser_download_url" -Match '.msixbundle' | Select-Object -ExpandProperty "browser_download_url" # Download Invoke-WebRequest -Uri $URL -OutFile "Setup.msix" -UseBasicParsing # Install Add-AppxPackage -Path "Setup.msix" # Cleanup install package Remove-Item "Setup.msix" [ScriptHelpers]::PrintSuccess("Successfully installed latest winget version") return $true } catch { [ScriptHelpers]::PrintError("Failed to install the latest winget version") return $false } } static [bool] InstallWingetPackage($packageId){ try { winget install --silent --accept-package-agreements --accept-source-agreements --force --disable-interactivity --exact --id $packageId [ScriptHelpers]::PrintSuccess("Successfully installed package via winget: $packageId") return $true } catch { [ScriptHelpers]::PrintError("Failed to install package via winget: $packageId") return $false } } static [bool] RemoveWindowsWidgets($packageId){ try { winget uninstall "Windows Web Experience pack" [ScriptHelpers]::PrintSuccess("Successfully removed Win11 widgets") return $true } catch { [ScriptHelpers]::PrintError("Failed to remove Win11 widgets") return $false } } } class Graphics { static [bool] DisableTdr(){ try { Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\GraphicsDrivers' -Name 'TdrDelay' -Value '60' -Type Dword [ScriptHelpers]::PrintSuccess("Successfully adjusted graphics TDR to a reasonable level") return $true } catch { [ScriptHelpers]::PrintError("Failed to adjust graphics TDR to a reasonable level") return $false } } } class Network { static [bool] DisableNetworkThrottling(){ try { Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile' -Name 'NetworkThrottlingIndex' -Value '0xffffffff' -Type Dword [ScriptHelpers]::PrintSuccess("Successfully disabled network throttling") return $true } catch { [ScriptHelpers]::PrintError("Failed to disable network throttling") return $false } } } class CPU { static [bool] DisableHpet(){ $hpetSuccessMessage = "operation completed successfully" $disableHpetClock = (bcdedit /set useplatformclock no) $disableHpetTick = (bcdedit /set useplatformtick yes) $disableHpetDynamicTick = (bcdedit /set disabledynamictick yes) if ($disableHpetClock.Contains($hpetSuccessMessage) -and $disableHpetTick.Contains($hpetSuccessMessage) -and $disableHpetDynamicTick.Contains($hpetSuccessMessage) ){ [ScriptHelpers]::PrintSuccess("Successfully disabled HPET") return $true } [ScriptHelpers]::PrintError("Failed to disable HPET") return $false } } class PowerPlan { static [System.Collections.Generic.List[string]] GetPowerPlans(){ $powerPlans = (powercfg /list | Select-String 'GUID' | ForEach-Object { $_ -replace '.*:\s+([^\s]+)\s*$', '$1' }) return $powerPlans } static [string] GetCurrentPowerPlan(){ $currentPowerPlan = (powercfg /getactivescheme | Select-String 'GUID' | ForEach-Object { $_ -replace '.*:\s+([^\s]+)\s*$', '$1' }) return $currentPowerPlan } static [string] GetPowerPlanGuid($powerPlanName){ $powerPlans = [PowerPlan]::GetPowerPlans() foreach ($plan in $powerPlans) { if ($plan.ToLower().Contains($powerPlanName.ToLower())) { $pattern += "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" $planMatches = [regex]::Matches($plan, $pattern) return $planMatches[0] } } return $null } static [bool] EnforceUltimatePerformancePlan(){ $powerPlans = [PowerPlan]::GetPowerPlans() foreach ($plan in $powerPlans){ if ($plan.ToLower().Contains("ultimate performance")) { [ScriptHelpers]::PrintSuccess("Ultimate Performance power plan already exists, skipping creation") return $true } } [ScriptHelpers]::PrintSuccess("Ultimate Performance power plan wasn't found, creating...") $powerPlanConfig = (powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61) if ($powerPlanConfig.Contains('(Ultimate Performance)')) { [ScriptHelpers]::PrintSuccess("Successfully created the Ultimate Performance power plan") return $true } [ScriptHelpers]::PrintError("Failed to create the Ultimate Performance power plan") return $false } static [bool] SetPowerPlan($powerPlanGuid){ $setPowerPlan = (powercfg /setactive $powerPlanGuid) if (-not ($null -eq $setPowerPlan)) { [ScriptHelpers]::PrintError("Failed to set desired power plan: $powerPlanGuid") return $false } [ScriptHelpers]::PrintSuccess("Successfully enforced the desired power plan: $powerPlanGuid") return $true } static [bool] EnforcePowerPlan($powerPlanName){ $powerPlanGuidDesired = [PowerPlan]::GetPowerPlanGuid($powerPlanName) $powerPlanSet = [PowerPlan]::SetPowerPlan($powerPlanGuidDesired) $currentPowerPlan = [PowerPlan]::GetCurrentPowerPlan() if ($powerPlanSet) { [ScriptHelpers]::PrintSuccess("Desired power plan configured: $currentPowerPlan") return $true } [ScriptHelpers]::PrintError("Failed to configure the desired power plan, current plan: $currentPowerPlan") return $false } } # endregion