Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Disable unnecessary services
- $services = @(
- "wsearch", # Windows Search
- "SysMain", # Superfetch
- "wuauserv" # Windows Update
- )
- foreach ($service in $services) {
- Set-Service -Name $service -StartupType Disabled
- Stop-Service -Name $service -Force
- }
- # Set performance options to 'Adjust for best performance'
- $regPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects"
- $regValue = "VisualFXSetting"
- if (Test-Path $regPath) {
- Set-ItemProperty -Path $regPath -Name $regValue -Value 2
- } else {
- New-Item -Path $regPath -Force
- New-ItemProperty -Path $regPath -Name $regValue -Value 2 -Force
- }
- # Adjust virtual memory (custom size)
- $minPageFile = 2048
- $maxPageFile = 4096
- $computer = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges
- $computer.AutomaticManagedPagefile = $false
- $computer.Put()
- $pageFile = Get-WmiObject Win32_PageFileSetting
- if ($pageFile) {
- $pageFile.InitialSize = $minPageFile
- $pageFile.MaximumSize = $maxPageFile
- $pageFile.Put()
- } else {
- ([WmiClass]"\\.\root\cimv2:Win32_PageFileSetting").Create("C:\pagefile.sys", $minPageFile, $maxPageFile)
- }
- # Disable startup programs
- $startupPrograms = @(
- "Sidebar",
- "AdobeARM",
- "QuickTime Task"
- )
- foreach ($program in $startupPrograms) {
- $task = Get-ScheduledTask | Where-Object {$_.TaskName -like "*$program*"}
- if ($task) {
- Disable-ScheduledTask -TaskName $task.TaskName
- }
- }
- # Disk cleanup
- Start-Process cleanmgr -ArgumentList "/sagerun:1" -NoNewWindow -Wait
- # Defragment the hard drive
- defrag C: -f
- # Set power plan to high performance
- powercfg -setactive SCHEME_MIN
- # Optimize network settings (disable QoS Packet Scheduler)
- $networkAdapters = Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object {$_.IPEnabled -eq $true}
- foreach ($adapter in $networkAdapters) {
- $adapter.SettingID
- Set-WmiInstance -Path Win32_NetworkAdapterSetting.SettingID=$adapter.SettingID -Arguments @{QoSPacketSchedulerEnabled=$false}
- }
- # Disable visual effects (already done through registry, but ensuring it's enforced)
- $visualEffects = @(
- "MinAnimate",
- "FontSmoothing"
- )
- foreach ($effect in $visualEffects) {
- Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name $effect -Value 0
- }
- # Restart to apply changes
- Write-Output "Optimizations applied. It's recommended to restart the server to apply all changes."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement