├── README.md └── WindowsUpdateManager.ps1 /README.md: -------------------------------------------------------------------------------- 1 | # WindowsUpdateManager 2 | 3 | ------------------------------------------------- 4 | Windows Update Manager is a PowerShell script that takes advantage of the PSWindowsUpdate Module to allow users more options when managing updates 5 | 6 | Working on Windows 10 and 11 7 | 8 | Run Script from Console 9 | ```` 10 | Set-ExecutionPolicy Unrestricted -Force 11 | iwr https://raw.githubusercontent.com/zoicware/WindowsUpdateManager/main/WindowsUpdateManager.ps1 | iex 12 | ```` 13 | 14 | # Preview 15 | ---------------------------------------------------------- 16 | ![image](https://github.com/zoicware/WindowsUpdateManager/assets/118035521/3f234b49-dc47-4468-b439-3074b9c2bba5) 17 | ![image](https://github.com/zoicware/WindowsUpdateManager/assets/118035521/b062f629-de2e-400d-96a6-00d539453b10) 18 | -------------------------------------------------------------------------------- /WindowsUpdateManager.ps1: -------------------------------------------------------------------------------- 1 | #windows update manager by zoic 2 | 3 | If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) { 4 | Start-Process PowerShell.exe -ArgumentList ("-NoProfile -ExecutionPolicy Bypass -File `"{0}`"" -f $PSCommandPath) -Verb RunAs 5 | Exit 6 | } 7 | 8 | 9 | try { 10 | 11 | Get-InstalledModule -Name PSWindowsUpdate -ErrorAction Stop | Out-Null 12 | 13 | } 14 | catch { 15 | $ProgressPreference = 'SilentlyContinue' 16 | Write-Host 'Installing Powershell Update Module...' 17 | Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null 18 | Install-Module PSWindowsUpdate -SkipPublisherCheck -Force | Out-Null 19 | Clear-Host 20 | } 21 | finally { 22 | Import-Module -Name PSWindowsUpdate -Force 23 | } 24 | 25 | 26 | function getAutoUpdates { 27 | 28 | $settings = Get-WUSettings 29 | 30 | $autoUpdate = $settings.NoAutoUpdate 31 | return $autoUpdate 32 | } 33 | 34 | function getWUServer { 35 | 36 | $settings = Get-WUSettings 37 | 38 | $WUServer = $settings.WUServer 39 | return $WUServer 40 | 41 | } 42 | 43 | function getWUConnection { 44 | 45 | $settings = Get-WUSettings 46 | 47 | $WUCon = $settings.DoNotConnectToWindowsUpdateInternetLocations 48 | return $WUCon 49 | 50 | } 51 | 52 | function getWUService { 53 | $regkey = Get-ItemPropertyValue 'registry::HKLM\SYSTEM\CurrentControlSet\Services\UsoSvc' -Name 'Start' 54 | $uso = Get-WmiObject -Class Win32_Service | Where-Object { $_.Name -eq 'UsoSvc' } 55 | 56 | if ($regkey -eq '2' -and $uso.State -eq 'Running') { 57 | return 'WU Service Running and Enabled' 58 | 59 | } 60 | elseif ($regkey -eq '2' -and $uso.State -ne 'Running') { 61 | return 'WU Service needs restart' 62 | 63 | } 64 | else { 65 | return 'WU Service Disabled' 66 | 67 | } 68 | } 69 | 70 | function getDOService { 71 | #get service 72 | $service = (Get-Service -Name DoSvc).Status 73 | if ($service -eq 'Running') { 74 | return 'Delivery Optimization Running' 75 | } 76 | else { 77 | return 'Delivery Optimization Stopped' 78 | } 79 | } 80 | 81 | Add-Type -AssemblyName System.Windows.Forms 82 | [System.Windows.Forms.Application]::EnableVisualStyles() 83 | 84 | $form = New-Object System.Windows.Forms.Form 85 | $form.Text = 'Windows Update Manager' 86 | $form.Size = New-Object System.Drawing.Size(490, 420) 87 | $form.StartPosition = 'CenterScreen' 88 | $form.BackColor = 'Black' 89 | 90 | $TabControl = New-Object System.Windows.Forms.TabControl 91 | $TabControl.Location = New-Object System.Drawing.Size(-4, 15) 92 | $TabControl.Size = New-Object System.Drawing.Size(490, 460) 93 | $TabControl.BackColor = [System.Drawing.Color]::FromArgb(45, 45, 48) 94 | 95 | 96 | $TabPage1 = New-Object System.Windows.Forms.TabPage 97 | $TabPage1.Text = 'Update Configuration' 98 | $TabPage1.BackColor = [System.Drawing.Color]::FromArgb(45, 45, 48) 99 | 100 | 101 | $TabPage2 = New-Object System.Windows.Forms.TabPage 102 | $TabPage2.Text = 'Update Manager' 103 | $TabPage2.BackColor = [System.Drawing.Color]::FromArgb(45, 45, 48) 104 | 105 | 106 | $TabControl.Controls.Add($TabPage1) 107 | $TabControl.Controls.Add($TabPage2) 108 | $Form.Controls.Add($TabControl) 109 | 110 | $label1 = New-Object System.Windows.Forms.Label 111 | $label1.Location = New-Object System.Drawing.Point(30, 10) 112 | $label1.Size = New-Object System.Drawing.Size(150, 25) 113 | $label1.Text = 'Enable Options:' 114 | $label1.ForeColor = 'White' 115 | $label1.Font = New-Object System.Drawing.Font('Segoe UI', 13) 116 | $form.Controls.Add($label1) 117 | $TabPage1.Controls.Add($label1) 118 | 119 | $label2 = New-Object System.Windows.Forms.Label 120 | $label2.Location = New-Object System.Drawing.Point(220, 10) 121 | $label2.Size = New-Object System.Drawing.Size(150, 25) 122 | $label2.Text = 'Disable Options:' 123 | $label2.ForeColor = 'White' 124 | $label2.Font = New-Object System.Drawing.Font('Segoe UI', 13) 125 | $form.Controls.Add($label2) 126 | $TabPage1.Controls.Add($label2) 127 | 128 | 129 | $btn1 = New-Object Windows.Forms.Button 130 | $btn1.Text = 'Disable Updates' 131 | $btn1.Location = New-Object Drawing.Point(220, 40) 132 | $btn1.Size = New-Object Drawing.Size(130, 35) 133 | $btn1.Add_Click({ 134 | 135 | Write-Host '-----------------DISABLING UPDATES-----------------' 136 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'WUServer' /t REG_SZ /d 'https://DoNotUpdateWindows10.com/' /f 137 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'WUStatusServer' /t REG_SZ /d 'https://DoNotUpdateWindows10.com/' /f 138 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'UpdateServiceUrlAlternate' /t REG_SZ /d 'https://DoNotUpdateWindows10.com/' /f 139 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'SetProxyBehaviorForUpdateDetection' /t REG_DWORD /d '0' /f 140 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'SetDisableUXWUAccess' /t REG_DWORD /d '1' /f 141 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'DoNotConnectToWindowsUpdateInternetLocations' /t REG_DWORD /d '1' /f 142 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'ExcludeWUDriversInQualityUpdate' /t REG_DWORD /d '1' /f 143 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' /v 'NoAutoUpdate' /t REG_DWORD /d '1' /f 144 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' /v 'UseWUServer' /t REG_DWORD /d '1' /f 145 | Reg.exe add 'HKLM\SYSTEM\CurrentControlSet\Services\UsoSvc' /v 'Start' /t REG_DWORD /d '4' /f 146 | gpupdate /force 147 | 148 | Write-Host '-----------------UPDATES DISABLED-----------------' 149 | 150 | 151 | }) 152 | $form.Controls.Add($btn1) 153 | $btn1.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 154 | $btn1.ForeColor = [System.Drawing.Color]::White 155 | $btn1.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 156 | $btn1.FlatAppearance.BorderSize = 0 157 | $btn1.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 158 | $btn1.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 159 | $TabPage1.Controls.Add($btn1) 160 | 161 | 162 | $btn2 = New-Object Windows.Forms.Button 163 | $btn2.Text = 'Pause Updates' 164 | $btn2.Location = New-Object Drawing.Point(30, 80) 165 | $btn2.Size = New-Object Drawing.Size(130, 35) 166 | $btn2.Add_Click({ 167 | Write-Host '-----------------PAUSING UPDATES-----------------' 168 | 169 | 170 | 171 | $form2 = New-Object System.Windows.Forms.Form 172 | $form2.Text = 'Pause Updates' 173 | $form2.Size = New-Object System.Drawing.Size(300, 150) 174 | $form2.StartPosition = 'CenterScreen' 175 | $form2.BackColor = [System.Drawing.Color]::FromArgb(45, 45, 48) 176 | 177 | $label = New-Object System.Windows.Forms.Label 178 | $label.Location = New-Object System.Drawing.Point(10, 20) 179 | $label.Size = New-Object System.Drawing.Size(280, 20) 180 | $label.Text = 'Enter the number of days to pause updates:' 181 | $label.ForeColor = 'White' 182 | $form2.Controls.Add($label) 183 | 184 | 185 | $textBox = New-Object System.Windows.Forms.TextBox 186 | $textBox.Location = New-Object System.Drawing.Point(10, 50) 187 | $textBox.Size = New-Object System.Drawing.Size(100, 20) 188 | #prevent letters from being typed 189 | $textBox.Add_KeyPress({ 190 | param($sender, $e) 191 | 192 | # Check if the key pressed is not a digit or control key 193 | if (-not [char]::IsDigit($e.KeyChar) -and -not [char]::IsControl($e.KeyChar)) { 194 | # If it's not, handle the event by setting Handled to true 195 | $e.Handled = $true 196 | } 197 | }) 198 | $form2.Controls.Add($textBox) 199 | 200 | 201 | $button = New-Object System.Windows.Forms.Button 202 | $button.Location = New-Object System.Drawing.Point(120, 80) 203 | $button.Size = New-Object System.Drawing.Size(75, 23) 204 | $button.Text = 'OK' 205 | $button.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 206 | $button.ForeColor = [System.Drawing.Color]::White 207 | $button.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 208 | $button.FlatAppearance.BorderSize = 0 209 | $button.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 210 | $button.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 211 | $button.Add_Click({ 212 | 213 | $days = [int]$textBox.Text 214 | 215 | $form2.Close() 216 | 217 | if ($days -gt 500) { 218 | Write-Host 'Days greater than 500...Pausing for MAX [500 days]' 219 | $days = 500 220 | } 221 | 222 | $pause = (Get-Date).AddDays($days) 223 | $today = Get-Date 224 | $today = $today.ToUniversalTime().ToString( 'yyyy-MM-ddTHH:mm:ssZ' ) 225 | $pause = $pause.ToUniversalTime().ToString( 'yyyy-MM-ddTHH:mm:ssZ' ) 226 | Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings' -Name 'PauseUpdatesExpiryTime' -Value $pause -Force 227 | Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings' -Name 'PauseFeatureUpdatesEndTime' -Value $pause -Force 228 | Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings' -Name 'PauseFeatureUpdatesStartTime' -Value $today -Force 229 | Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings' -Name 'PauseQualityUpdatesEndTime' -Value $pause -Force 230 | Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings' -Name 'PauseQualityUpdatesStartTime' -Value $today -Force 231 | Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings' -Name 'PauseUpdatesStartTime' -Value $today -Force 232 | Write-Host "-----------------UPDATES PAUSED FOR $DAYS DAYS-----------------" 233 | 234 | }) 235 | $form2.Controls.Add($button) 236 | 237 | 238 | $form2.ShowDialog() 239 | 240 | 241 | 242 | 243 | 244 | 245 | }) 246 | $form.Controls.Add($btn2) 247 | $btn2.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 248 | $btn2.ForeColor = [System.Drawing.Color]::White 249 | $btn2.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 250 | $btn2.FlatAppearance.BorderSize = 0 251 | $btn2.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 252 | $btn2.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 253 | $TabPage1.Controls.Add($btn2) 254 | 255 | $btn3 = New-Object Windows.Forms.Button 256 | $btn3.Text = 'Disable Drivers in Update' 257 | $btn3.Location = New-Object Drawing.Point(220, 80) 258 | $btn3.Size = New-Object Drawing.Size(130, 35) 259 | $btn3.Add_Click({ 260 | Write-Host '-----------------DISABLING DRIVERS IN WINDOWS UPDATE-----------------' 261 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'ExcludeWUDriversInQualityUpdate' /t REG_DWORD /d '1' /f 262 | Reg.exe add 'HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings' /v 'ExcludeWUDriversInQualityUpdate' /t REG_DWORD /d '1' /f 263 | gpupdate /force 264 | 265 | Write-Host '-----------------DRIVERS IN UPDATES DISABLED-----------------' 266 | }) 267 | $form.Controls.Add($btn3) 268 | $btn3.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 269 | $btn3.ForeColor = [System.Drawing.Color]::White 270 | $btn3.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 271 | $btn3.FlatAppearance.BorderSize = 0 272 | $btn3.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 273 | $btn3.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 274 | $TabPage1.Controls.Add($btn3) 275 | 276 | $btn4 = New-Object Windows.Forms.Button 277 | $btn4.Text = 'Disable Auto Driver Searching' 278 | $btn4.Location = New-Object Drawing.Point(220, 160) 279 | $btn4.Size = New-Object Drawing.Size(130, 35) 280 | $btn4.Add_Click({ 281 | Write-Host '-----------------DISABLING DRIVER SEARCHING-----------------' 282 | Reg.exe add 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\DriverSearching' /v 'SearchOrderConfig' /t REG_DWORD /d '0' /f 283 | Write-Host '-----------------DRIVER SEARCHING DISABLED-----------------' 284 | }) 285 | $form.Controls.Add($btn4) 286 | $btn4.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 287 | $btn4.ForeColor = [System.Drawing.Color]::White 288 | $btn4.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 289 | $btn4.FlatAppearance.BorderSize = 0 290 | $btn4.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 291 | $btn4.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 292 | $TabPage1.Controls.Add($btn4) 293 | 294 | 295 | $btn5 = New-Object Windows.Forms.Button 296 | $btn5.Text = 'Disable Optional Updates' 297 | $btn5.Location = New-Object Drawing.Point(220, 120) 298 | $btn5.Size = New-Object Drawing.Size(130, 35) 299 | $btn5.Add_Click({ 300 | Write-Host '-----------------DISABLING OPTIONAL UPDATES (W11 ONLY)-----------------' 301 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'SetAllowOptionalContent' /t REG_DWORD /d '0' /f >$null 302 | gpupdate /force 303 | Write-Host '-----------------OPTIONAL UPDATES DISABLED-----------------' 304 | }) 305 | $form.Controls.Add($btn5) 306 | $btn5.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 307 | $btn5.ForeColor = [System.Drawing.Color]::White 308 | $btn5.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 309 | $btn5.FlatAppearance.BorderSize = 0 310 | $btn5.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 311 | $btn5.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 312 | $TabPage1.Controls.Add($btn5) 313 | 314 | 315 | $btn6 = New-Object Windows.Forms.Button 316 | $btn6.Text = 'Enable Updates' 317 | $btn6.Location = New-Object Drawing.Point(30, 40) 318 | $btn6.Size = New-Object Drawing.Size(130, 35) 319 | $btn6.Add_Click({ 320 | Write-Host '-----------------ENABLING UPDATES-----------------' 321 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'WUServer' /f 322 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'WUStatusServer' /f 323 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'UpdateServiceUrlAlternate' /f 324 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'SetProxyBehaviorForUpdateDetection' /f 325 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'SetDisableUXWUAccess' /f 326 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'DoNotConnectToWindowsUpdateInternetLocations' /f 327 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'ExcludeWUDriversInQualityUpdate' /f 328 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' /v 'NoAutoUpdate' /f 329 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' /v 'UseWUServer' /f 330 | Reg.exe add 'HKLM\SYSTEM\CurrentControlSet\Services\UsoSvc' /v 'Start' /t REG_DWORD /d '2' /f 331 | #remove pause values 332 | Reg.exe delete 'HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings' /v 'PauseUpdatesExpiryTime' /f >$null 2>&1 333 | Reg.exe delete 'HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings' /v 'PauseFeatureUpdatesEndTime' /f >$null 2>&1 334 | Reg.exe delete 'HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings' /v 'PauseFeatureUpdatesStartTime' /f >$null 2>&1 335 | Reg.exe delete 'HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings' /v 'PauseQualityUpdatesEndTime' /f >$null 2>&1 336 | Reg.exe delete 'HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings' /v 'PauseQualityUpdatesStartTime' /f >$null 2>&1 337 | Reg.exe delete 'HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings' /v 'PauseUpdatesStartTime' /f >$null 2>&1 338 | gpupdate /force 339 | Write-Host '-----------------UPDATES ENABLED-----------------' 340 | }) 341 | $form.Controls.Add($btn6) 342 | $btn6.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 343 | $btn6.ForeColor = [System.Drawing.Color]::White 344 | $btn6.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 345 | $btn6.FlatAppearance.BorderSize = 0 346 | $btn6.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 347 | $btn6.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 348 | $TabPage1.Controls.Add($btn6) 349 | 350 | $btn7 = New-Object Windows.Forms.Button 351 | $btn7.Text = 'Disable Update Restart Notifications' 352 | $btn7.Location = New-Object Drawing.Point(220, 200) 353 | $btn7.Size = New-Object Drawing.Size(130, 35) 354 | $btn7.Add_Click({ 355 | Write-Host '-----------------DISABLING NOTIFICATIONS-----------------' 356 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' /v 'NoAUShutdownOption' /t REG_DWORD /d '1' /f 357 | Reg.exe add 'HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings' /v 'RestartNotificationsAllowed2' /t REG_DWORD /d '0' /f 358 | gpupdate /force 359 | Write-Host '-----------------NOTIFICATIONS DISABLED-----------------' 360 | }) 361 | $form.Controls.Add($btn7) 362 | $btn7.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 363 | $btn7.ForeColor = [System.Drawing.Color]::White 364 | $btn7.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 365 | $btn7.FlatAppearance.BorderSize = 0 366 | $btn7.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 367 | $btn7.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 368 | $TabPage1.Controls.Add($btn7) 369 | 370 | 371 | $btn8 = New-Object Windows.Forms.Button 372 | $btn8.Text = 'Defer Feature and Quality Updates' 373 | $btn8.Location = New-Object Drawing.Point(220, 240) 374 | $btn8.Size = New-Object Drawing.Size(130, 35) 375 | $btn8.Add_Click({ 376 | Write-Host '-----------------DEFERING FEATURE AND QUALITY UPDATES FOR [MAX] DAYS-----------------' 377 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'DeferFeatureUpdates' /t REG_DWORD /d '1' /f >$null 378 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'DeferFeatureUpdatesPeriodInDays' /t REG_DWORD /d '730' /f >$null 379 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'DeferQualityUpdates' /t REG_DWORD /d '1' /f >$null 380 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'DeferQualityUpdatesPeriodInDays' /t REG_DWORD /d '730' /f >$null 381 | gpupdate /force 382 | Write-Host '-----------------DEFERED FEATURE UPDATES QUALITY UPDATES-----------------' 383 | }) 384 | $form.Controls.Add($btn8) 385 | $btn8.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 386 | $btn8.ForeColor = [System.Drawing.Color]::White 387 | $btn8.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 388 | $btn8.FlatAppearance.BorderSize = 0 389 | $btn8.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 390 | $btn8.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 391 | $TabPage1.Controls.Add($btn8) 392 | 393 | 394 | $btn9 = New-Object Windows.Forms.Button 395 | $btn9.Text = 'Disable Delivery Optimization' 396 | $btn9.Location = New-Object Drawing.Point(220, 280) 397 | $btn9.Size = New-Object Drawing.Size(130, 35) 398 | $btn9.Add_Click({ 399 | Write-Host '-----------------DISABLING DELIVERY OPTIMIZATION-----------------' 400 | Stop-Service -Name DoSvc -Force -ErrorAction SilentlyContinue 401 | Reg.exe add 'HKLM\SYSTEM\CurrentControlSet\Services\DoSvc' /v 'Start' /t REG_DWORD /d '4' /f 402 | Reg.exe add 'HKU\S-1-5-20\Software\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Settings' /v 'DownloadMode' /t REG_DWORD /d '0' /f 403 | Write-Host '-----------------DISABLED DELIVERY OPTIMIZATION-----------------' 404 | }) 405 | $form.Controls.Add($btn9) 406 | $btn9.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 407 | $btn9.ForeColor = [System.Drawing.Color]::White 408 | $btn9.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 409 | $btn9.FlatAppearance.BorderSize = 0 410 | $btn9.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 411 | $btn9.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 412 | $TabPage1.Controls.Add($btn9) 413 | 414 | 415 | $btn10 = New-Object Windows.Forms.Button 416 | $btn10.Text = 'Enable Optional Updates' 417 | $btn10.Location = New-Object Drawing.Point(30, 120) 418 | $btn10.Size = New-Object Drawing.Size(130, 35) 419 | $btn10.Add_Click({ 420 | Write-Host '-----------------ENABLING OPTIONAL UPDATES-----------------' 421 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'SetAllowOptionalContent' /f >$null 422 | gpupdate /force 423 | Write-Host '-----------------OPTIONAL UPDATES ENABLED-----------------' 424 | }) 425 | $form.Controls.Add($btn10) 426 | $btn10.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 427 | $btn10.ForeColor = [System.Drawing.Color]::White 428 | $btn10.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 429 | $btn10.FlatAppearance.BorderSize = 0 430 | $btn10.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 431 | $btn10.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 432 | $TabPage1.Controls.Add($btn10) 433 | 434 | 435 | $btn11 = New-Object Windows.Forms.Button 436 | $btn11.Text = 'Enable Auto Driver Searching' 437 | $btn11.Location = New-Object Drawing.Point(30, 160) 438 | $btn11.Size = New-Object Drawing.Size(130, 35) 439 | $btn11.Add_Click({ 440 | Write-Host '-----------------ENABLING AUTO DRIVER SEARCHING-----------------' 441 | Reg.exe add 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\DriverSearching' /v 'SearchOrderConfig' /t REG_DWORD /d '1' /f 442 | Write-Host '-----------------AUTO DRIVER SEARCHING ENABLED-----------------' 443 | }) 444 | $form.Controls.Add($btn11) 445 | $btn11.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 446 | $btn11.ForeColor = [System.Drawing.Color]::White 447 | $btn11.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 448 | $btn11.FlatAppearance.BorderSize = 0 449 | $btn11.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 450 | $btn11.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 451 | $TabPage1.Controls.Add($btn11) 452 | 453 | 454 | 455 | $btn12 = New-Object Windows.Forms.Button 456 | $btn12.Text = 'Enable Update Restart Notifications' 457 | $btn12.Location = New-Object Drawing.Point(30, 200) 458 | $btn12.Size = New-Object Drawing.Size(130, 35) 459 | $btn12.Add_Click({ 460 | Write-Host '-----------------ENABLING UPDATE RESTART NOTIFICATIONS-----------------' 461 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' /v 'NoAUShutdownOption' /f 462 | Reg.exe add 'HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings' /v 'RestartNotificationsAllowed2' /t REG_DWORD /d '1' /f 463 | gpupdate /force 464 | Write-Host '-----------------UPDATE RESTART NOTIFICATIONS ENABLED-----------------' 465 | }) 466 | $form.Controls.Add($btn12) 467 | $btn12.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 468 | $btn12.ForeColor = [System.Drawing.Color]::White 469 | $btn12.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 470 | $btn12.FlatAppearance.BorderSize = 0 471 | $btn12.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 472 | $btn12.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 473 | $TabPage1.Controls.Add($btn12) 474 | 475 | 476 | $btn13 = New-Object Windows.Forms.Button 477 | $btn13.Text = 'Allow Feature and Quality Updates' 478 | $btn13.Location = New-Object Drawing.Point(30, 240) 479 | $btn13.Size = New-Object Drawing.Size(130, 35) 480 | $btn13.Add_Click({ 481 | Write-Host '-----------------ALLOWING FEATURE AND QUALITY UPDATES-----------------' 482 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'DeferFeatureUpdates' /f 483 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'DeferFeatureUpdatesPeriodInDays' /f 484 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'DeferQualityUpdates' /f 485 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'DeferQualityUpdatesPeriodInDays' /f 486 | gpupdate /force 487 | Write-Host '-----------------FEATURE AND QUALITY UPDATES ENABLED-----------------' 488 | }) 489 | $form.Controls.Add($btn13) 490 | $btn13.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 491 | $btn13.ForeColor = [System.Drawing.Color]::White 492 | $btn13.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 493 | $btn13.FlatAppearance.BorderSize = 0 494 | $btn13.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 495 | $btn13.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 496 | $TabPage1.Controls.Add($btn13) 497 | 498 | 499 | $btn14 = New-Object Windows.Forms.Button 500 | $btn14.Text = 'Enable Delivery Optimization' 501 | $btn14.Location = New-Object Drawing.Point(30, 280) 502 | $btn14.Size = New-Object Drawing.Size(130, 35) 503 | $btn14.Add_Click({ 504 | Write-Host '-----------------ENABLING DELIVERY OPTIMIZATION-----------------' 505 | Reg.exe add 'HKLM\SYSTEM\CurrentControlSet\Services\DoSvc' /v 'Start' /t REG_DWORD /d '2' /f 506 | Reg.exe add 'HKLM\SYSTEM\CurrentControlSet\Services\DoSvc' /v 'DelayedAutostart' /t REG_DWORD /d '1' /f 507 | Reg.exe delete 'HKU\S-1-5-20\Software\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Settings' /v 'DownloadMode' /f 508 | Start-Service -Name DoSvc -ErrorAction SilentlyContinue 509 | Write-Host '-----------------DELIVERY OPTIMIZATION ENABLED-----------------' 510 | }) 511 | $form.Controls.Add($btn14) 512 | $btn14.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 513 | $btn14.ForeColor = [System.Drawing.Color]::White 514 | $btn14.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 515 | $btn14.FlatAppearance.BorderSize = 0 516 | $btn14.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 517 | $btn14.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 518 | $TabPage1.Controls.Add($btn14) 519 | 520 | #TAB 2 521 | 522 | $label = New-Object System.Windows.Forms.Label 523 | $label.Location = New-Object System.Drawing.Point(10, 20) 524 | $label.Size = New-Object System.Drawing.Size(280, 20) 525 | $label.Text = 'Update Dependencies:' 526 | $boldFont = New-Object System.Drawing.Font($label.Font, [System.Drawing.FontStyle]::Bold) 527 | $label.Font = $boldFont 528 | $label.ForeColor = 'White' 529 | $form.Controls.Add($label) 530 | $TabPage2.Controls.Add($label) 531 | 532 | $Global:label2 = New-Object System.Windows.Forms.Label 533 | $Global:label3 = New-Object System.Windows.Forms.Label 534 | $Global:label4 = New-Object System.Windows.Forms.Label 535 | $Global:label5 = New-Object System.Windows.Forms.Label 536 | $Global:label6 = New-Object System.Windows.Forms.Label 537 | function getDependencies { 538 | 539 | $label2.Location = New-Object System.Drawing.Point(15, 40) 540 | $label2.Size = New-Object System.Drawing.Size(180, 20) 541 | $label2.ForeColor = 'White' 542 | if (getAutoUpdates -eq 1) { $label2.Text = 'Auto Updates Disabled' } 543 | else { $label2.Text = 'Auto Updates Enabled' } 544 | $form.Controls.Add($label2) 545 | $TabPage2.Controls.Add($label2) 546 | 547 | $server = getWUServer 548 | 549 | $label3.Location = New-Object System.Drawing.Point(15, 60) 550 | $label3.Size = New-Object System.Drawing.Size(200, 30) 551 | $label3.ForeColor = 'White' 552 | if ($server -eq $null) { 553 | $server = 'Default' 554 | $label3.Size = New-Object System.Drawing.Size(200, 20) 555 | } 556 | $label3.Text = "Windows Update Server: $server" 557 | $form.Controls.Add($label3) 558 | $TabPage2.Controls.Add($label3) 559 | 560 | 561 | if ($server -ne 'Default') { 562 | $label4.Location = New-Object System.Drawing.Point(15, 90) 563 | } 564 | else { 565 | $label4.Location = New-Object System.Drawing.Point(15, 80) 566 | } 567 | $label4.Size = New-Object System.Drawing.Size(180, 20) 568 | $label4.ForeColor = 'White' 569 | if (getWUConnection -eq 1) { $label4.Text = 'Connect to WU Server Disabled' } 570 | else { $label4.Text = 'Connect to WU Server Enabled' } 571 | $form.Controls.Add($label4) 572 | $TabPage2.Controls.Add($label4) 573 | 574 | 575 | if ($server -ne 'Default') { 576 | $label5.Location = New-Object System.Drawing.Point(15, 110) 577 | } 578 | else { 579 | $label5.Location = New-Object System.Drawing.Point(15, 100) 580 | } 581 | $label5.Size = New-Object System.Drawing.Size(180, 20) 582 | $label5.ForeColor = 'White' 583 | $text = getWUService 584 | $label5.Text = $text 585 | $form.Controls.Add($label5) 586 | $TabPage2.Controls.Add($label5) 587 | 588 | 589 | if ($server -ne 'Default') { 590 | $label6.Location = New-Object System.Drawing.Point(15, 130) 591 | } 592 | else { 593 | $label6.Location = New-Object System.Drawing.Point(15, 120) 594 | } 595 | $label6.Size = New-Object System.Drawing.Size(180, 20) 596 | $label6.ForeColor = 'White' 597 | $text = getDOService 598 | $label6.Text = $text 599 | $form.Controls.Add($label6) 600 | $TabPage2.Controls.Add($label6) 601 | } 602 | getDependencies 603 | 604 | function refresh { 605 | $label2.Text = '' 606 | $label3.Text = '' 607 | $label4.Text = '' 608 | $label5.Text = '' 609 | $label6.Text = '' 610 | getDependencies 611 | } 612 | $refreshBttn = New-Object Windows.Forms.Button 613 | $refreshBttn.Text = 'Refresh' 614 | $refreshBttn.Location = New-Object Drawing.Point(10, 155) 615 | $refreshBttn.Size = New-Object Drawing.Size(70, 20) 616 | $refreshBttn.Add_Click({ 617 | refresh 618 | }) 619 | $form.Controls.Add($refreshBttn) 620 | $refreshBttn.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 621 | $refreshBttn.ForeColor = [System.Drawing.Color]::White 622 | $refreshBttn.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 623 | $refreshBttn.FlatAppearance.BorderSize = 0 624 | $refreshBttn.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 625 | $refreshBttn.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 626 | $TabPage2.Controls.Add($refreshBttn) 627 | 628 | 629 | 630 | $clearDOcache = New-Object Windows.Forms.Button 631 | $clearDOcache.Text = 'Clear Delivery Optimization Cache' 632 | $clearDOcache.Location = New-Object Drawing.Point(250, 40) 633 | $clearDOcache.Size = New-Object Drawing.Size(120, 35) 634 | $clearDOcache.Add_Click({ 635 | #clear delivery optmization cache 636 | Write-Host 'Clearing Delivery Optimization Cache' 637 | try { 638 | #will error if dosvc is disabled 639 | Delete-DeliveryOptimizationCache -Force -ErrorAction Stop 640 | } 641 | catch { 642 | #delete cache manually 643 | Remove-Item -Path 'C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\Windows\DeliveryOptimization\Cache\*' -Force -Recurse 644 | } 645 | Write-Host 'Cleared' 646 | }) 647 | $form.Controls.Add($clearDOcache) 648 | $clearDOcache.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 649 | $clearDOcache.ForeColor = [System.Drawing.Color]::White 650 | $clearDOcache.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 651 | $clearDOcache.FlatAppearance.BorderSize = 0 652 | $clearDOcache.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 653 | $clearDOcache.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 654 | $TabPage2.Controls.Add($clearDOcache) 655 | 656 | 657 | $clearUpdateCache = New-Object Windows.Forms.Button 658 | $clearUpdateCache.Text = 'Clear Windows Update Cache' 659 | $clearUpdateCache.Location = New-Object Drawing.Point(250, 90) 660 | $clearUpdateCache.Size = New-Object Drawing.Size(120, 35) 661 | $clearUpdateCache.Add_Click({ 662 | #clear windows update cache 663 | Write-Host 'Clearing Windows Update Cache' 664 | $wusvc = (Get-Service -Name wuauserv).Status 665 | $bits = (Get-Service -Name BITS).Status 666 | if (!($wusvc -eq 'Stopped')) { 667 | Stop-Service -Name wuauserv -Force 668 | } 669 | if (!($bits -eq 'Stopped')) { 670 | Stop-Service -Name BITS -Force 671 | } 672 | Remove-Item -Path 'C:\Windows\SoftwareDistribution\*' -Recurse -Force 673 | #start the services again if they were running 674 | if (!($wusvc -eq 'Stopped')) { 675 | Start-Service -Name wuauserv 676 | } 677 | if (!($bits -eq 'Stopped')) { 678 | Start-Service -Name BITS 679 | } 680 | Write-Host 'Cleared' 681 | }) 682 | $form.Controls.Add($clearUpdateCache) 683 | $clearUpdateCache.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 684 | $clearUpdateCache.ForeColor = [System.Drawing.Color]::White 685 | $clearUpdateCache.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 686 | $clearUpdateCache.FlatAppearance.BorderSize = 0 687 | $clearUpdateCache.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 688 | $clearUpdateCache.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 689 | $TabPage2.Controls.Add($clearUpdateCache) 690 | 691 | 692 | $checkingUpdates = New-Object System.Windows.Forms.Label 693 | $checkingUpdates.Location = New-Object System.Drawing.Point(10, 200) 694 | $checkingUpdates.Size = New-Object System.Drawing.Size(180, 20) 695 | $checkingUpdates.ForeColor = 'White' 696 | $checkingUpdates.BackColor = 'Black' 697 | $checkingUpdates.Text = 'Checking For Updates...' 698 | $checkingUpdates.Visible = $false 699 | $TabPage2.Controls.Add($checkingUpdates) 700 | 701 | $checkingUpdatesDriver = New-Object System.Windows.Forms.Label 702 | $checkingUpdatesDriver.Location = New-Object System.Drawing.Point(10, 200) 703 | $checkingUpdatesDriver.Size = New-Object System.Drawing.Size(180, 20) 704 | $checkingUpdatesDriver.ForeColor = 'White' 705 | $checkingUpdatesDriver.BackColor = 'Black' 706 | $checkingUpdatesDriver.Text = 'Checking For Driver Updates...' 707 | $checkingUpdatesDriver.Visible = $false 708 | $TabPage2.Controls.Add($checkingUpdatesDriver) 709 | 710 | $noDriverUpdates = New-Object System.Windows.Forms.Label 711 | $noDriverUpdates.Location = New-Object System.Drawing.Point(10, 200) 712 | $noDriverUpdates.Size = New-Object System.Drawing.Size(180, 20) 713 | $noDriverUpdates.ForeColor = 'White' 714 | $noDriverUpdates.BackColor = 'Black' 715 | $noDriverUpdates.Text = 'No Driver Updates Found...' 716 | $noDriverUpdates.Visible = $false 717 | $TabPage2.Controls.Add($noDriverUpdates) 718 | 719 | $noUpdates = New-Object System.Windows.Forms.Label 720 | $noUpdates.Location = New-Object System.Drawing.Point(10, 200) 721 | $noUpdates.Size = New-Object System.Drawing.Size(180, 20) 722 | $noUpdates.ForeColor = 'White' 723 | $noUpdates.BackColor = 'Black' 724 | $noUpdates.Text = 'No Updates Found...' 725 | $noUpdates.Visible = $false 726 | $TabPage2.Controls.Add($noUpdates) 727 | 728 | $checkedListBox = New-Object System.Windows.Forms.CheckedListBox 729 | $checkedListBox.Location = New-Object System.Drawing.Point(7, 190) 730 | $checkedListBox.Size = New-Object System.Drawing.Size(450, 120) 731 | $checkedListBox.BackColor = 'Black' 732 | $checkedListBox.ForeColor = 'White' 733 | $checkedListBox.ScrollAlwaysVisible = $false 734 | $TabPage2.Controls.Add($checkedListBox) 735 | 736 | 737 | $checkForUpdate = { 738 | $noDriverUpdates.Visible = $false 739 | $noUpdates.Visible = $false 740 | $showOnlyDriver.Checked = $false 741 | 742 | $checkingUpdates.Visible = $true 743 | $form.Refresh() 744 | $checkedListBox.Items.Clear() 745 | $Global:updates = Get-WindowsUpdate 746 | if (!$updates) { 747 | $noUpdates.Visible = $true 748 | } 749 | else { 750 | foreach ($update in $updates) { 751 | $checkedListBox.Items.Add($update.Title, $false) 752 | } 753 | 754 | if ($checkedListBox.Items.Count -gt 7) { 755 | $checkedListBox.ScrollAlwaysVisible = $true 756 | } 757 | } 758 | 759 | $checkingUpdates.Visible = $false 760 | } 761 | 762 | $checkUpdate = New-Object Windows.Forms.Button 763 | $checkUpdate.Text = 'Check for Updates' 764 | $checkUpdate.Location = New-Object Drawing.Point(30, 310) 765 | $checkUpdate.Size = New-Object Drawing.Size(120, 35) 766 | $checkUpdate.Add_Click({ 767 | &$checkForUpdate 768 | }) 769 | $form.Controls.Add($checkUpdate) 770 | $checkUpdate.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 771 | $checkUpdate.ForeColor = [System.Drawing.Color]::White 772 | $checkUpdate.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 773 | $checkUpdate.FlatAppearance.BorderSize = 0 774 | $checkUpdate.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 775 | $checkUpdate.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 776 | $TabPage2.Controls.Add($checkUpdate) 777 | 778 | 779 | $installSelectedUpdate = { 780 | Write-Host 'Installing Selected Updates' 781 | foreach ($selectedUpdate in $checkedListBox.CheckedItems.GetEnumerator()) { 782 | #get kb id 783 | if ($updates) { 784 | foreach ($update in $updates) { 785 | if ($update.Title -eq $selectedUpdate) { 786 | $KBID = $update.KB 787 | } 788 | } 789 | } 790 | else { 791 | #driver updates 792 | foreach ($driverUpdate in $driverUpdates) { 793 | if ($driverUpdate.Title -eq $selectedUpdate) { 794 | $KBID = $driverUpdate.KB 795 | } 796 | } 797 | } 798 | 799 | Write-Host 'Installing', $selectedUpdate 800 | Install-WindowsUpdate -KBArticleID $KBID -AcceptAll -IgnoreReboot 801 | } 802 | Write-Host 'Restart to Finish Updates' 803 | } 804 | 805 | $installSelected = New-Object Windows.Forms.Button 806 | $installSelected.Text = 'Install Selected Updates' 807 | $installSelected.Location = New-Object Drawing.Point(160, 310) 808 | $installSelected.Size = New-Object Drawing.Size(120, 35) 809 | $installSelected.Add_Click({ 810 | &$installSelectedUpdate 811 | }) 812 | $form.Controls.Add($installSelected) 813 | $installSelected.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 814 | $installSelected.ForeColor = [System.Drawing.Color]::White 815 | $installSelected.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 816 | $installSelected.FlatAppearance.BorderSize = 0 817 | $installSelected.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 818 | $installSelected.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 819 | $TabPage2.Controls.Add($installSelected) 820 | 821 | 822 | $installAllUpdates = { 823 | #check update server 824 | $server = getWUServer 825 | $serverConnect = getWUConnection 826 | if ($server -ne $null -or $serverConnect) { 827 | #enable connection so that get-windowsupdate works 828 | Write-host 'Connect to Windows Update Location Disabled...' 829 | Write-Host 'Enabling Connection' 830 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'DoNotConnectToWindowsUpdateInternetLocations' /f >$null 2>&1 831 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'WUServer' /f >$null 2>&1 832 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'WUStatusServer' /f >$null 2>&1 833 | Reg.exe delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'UpdateServiceUrlAlternate' /f >$null 2>&1 834 | } 835 | 836 | Write-Host 'Installing All Updates' 837 | $allupdates = Get-WindowsUpdate 838 | if (!$allupdates) { 839 | Write-Host 'No Updates Found' 840 | } 841 | else { 842 | foreach ($update in $allupdates) { 843 | Write-Host "Installing $($update.Title)" 844 | Install-WindowsUpdate -KBArticleID $update.KB -AcceptAll -IgnoreReboot 845 | } 846 | if ($server -ne $null -or $serverConnect) { 847 | Write-Host 'Disabling Windows Update Location Connectivity' 848 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'WUServer' /t REG_SZ /d 'https://DoNotUpdateWindows10.com/' /f 849 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'WUStatusServer' /t REG_SZ /d 'https://DoNotUpdateWindows10.com/' /f 850 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'UpdateServiceUrlAlternate' /t REG_SZ /d 'https://DoNotUpdateWindows10.com/' /f 851 | Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' /v 'DoNotConnectToWindowsUpdateInternetLocations' /t REG_DWORD /d '1' /f 852 | } 853 | 854 | Write-Host 'Restart To Finish Updates' 855 | 856 | } 857 | } 858 | 859 | $installALL = New-Object Windows.Forms.Button 860 | $installALL.Text = 'Install All Updates' 861 | $installALL.Location = New-Object Drawing.Point(290, 310) 862 | $installALL.Size = New-Object Drawing.Size(120, 35) 863 | $installALL.Add_Click({ 864 | &$installAllUpdates 865 | }) 866 | $form.Controls.Add($installALL) 867 | $installALL.BackColor = [System.Drawing.Color]::FromArgb(30, 30, 30) 868 | $installALL.ForeColor = [System.Drawing.Color]::White 869 | $installALL.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 870 | $installALL.FlatAppearance.BorderSize = 0 871 | $installALL.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 872 | $installALL.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 873 | $TabPage2.Controls.Add($installALL) 874 | 875 | 876 | $showDriver = { 877 | if ($showOnlyDriver.Checked) { 878 | $noDriverUpdates.Visible = $false 879 | $noUpdates.Visible = $false 880 | 881 | $checkedListBox.Items.Clear() 882 | $checkingUpdatesDriver.Visible = $true 883 | $form.Refresh() 884 | 885 | $Global:driverUpdates = Get-WindowsUpdate -UpdateType Driver 886 | if (!$driverUpdates) { 887 | $noDriverUpdates.Visible = $true 888 | } 889 | foreach ($driverUpdate in $driverUpdates) { 890 | $checkedListBox.Items.Add($driverUpdate.Title, $false) 891 | } 892 | #show scroll bar if there is more than 7 updates 893 | if ($checkedListBox.Items.Count -gt 7) { 894 | $checkedListBox.ScrollAlwaysVisible = $true 895 | } 896 | 897 | $checkingUpdatesDriver.Visible = $false 898 | } 899 | else { 900 | $noDriverUpdates.Visible = $false 901 | if ($updates) { 902 | $checkedListBox.Items.Clear() 903 | foreach ($update in $updates) { 904 | $checkedListBox.Items.Add($update.Title, $false) 905 | } 906 | } 907 | } 908 | } 909 | 910 | $showOnlyDriver = New-Object System.Windows.Forms.CheckBox 911 | $showOnlyDriver.Location = New-Object System.Drawing.Point(250, 170) 912 | $showOnlyDriver.Size = New-Object System.Drawing.Size(170, 20) 913 | $showOnlyDriver.ForeColor = 'White' 914 | $showOnlyDriver.Text = 'Show Only Driver Updates' 915 | $showOnlyDriver.add_CheckedChanged($showDriver) 916 | $TabPage2.Controls.Add($showOnlyDriver) 917 | 918 | 919 | $Form.Add_Shown({ $Form.Activate() }) 920 | $form.ShowDialog() | Out-Null 921 | --------------------------------------------------------------------------------