@@ -18,29 +18,30 @@ Legal notice: This script is provided without any warranty; without even the imp
1818Open 'Windows PowerShell' as Administrator on your WSUS server, then run these commands:
1919
2020``` powershell
21- # Update PowerShellGet for Windows PowerShell 5.1 - https://learn.microsoft.com/en-us/powershell/gallery/powershellget/update-powershell-51?view=powershellget-3.x
22- Install-Module -Name PowerShellGet -AllowClobber -Force
23- # (When prompted if you want PowerShellGet to install and import the NuGet provider, respond with 'Y')
24-
25- # Install latest version of SQLServer module - https://learn.microsoft.com/en-us/powershell/sql-server/download-sql-server-ps-module?view=sqlserver-ps
26- Install-Module -Name SqlServer
27- # (When prompted if you want to install the modules from 'PSGallery', respond with 'Y')
28-
29- # Change to Update Services installation directory
30- Set-Location "$env:ProgramFiles\Update Services"
31-
32- # Download latest version of the script to "%ProgramFiles%\Update Services\Update-WSUSComputerOperatingSystems.ps1"
33- Invoke-WebRequest -Uri "https://raw.githubusercontent.com/Borgquite/Update-WSUSComputerOperatingSystems/refs/heads/main/Update-WSUSComputerOperatingSystems.ps1" -OutFile Update-WSUSComputerOperatingSystems.ps1
34-
35- # Create a new scheduled task to run at midnight daily for up to 2 hours on a local Windows Internal Database instance
36- Register-ScheduledTask -TaskName "WSUS Update Operating Systems" `
37- -User 'SYSTEM' `
38- -Action (New-ScheduledTaskAction -Execute '%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe' `
39- -Argument '-NoProfile -NonInteractive -ExecutionPolicy Bypass -File "%ProgramFiles%\Update Services\Update-WSUSComputerOperatingSystems.ps1" -SQLServerInstance "\\.\pipe\MICROSOFT##WID\tsql\query" -Encrypt Optional' `
40- -WorkingDirectory '%ProgramFiles%\Update Services') `
41- -Settings (New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan -Hours 2)) `
42- -Trigger (New-ScheduledTaskTrigger -At "00:00:00" -Daily)
43- # Update \\.\pipe\MICROSOFT##WID\tsql\query in the above command to SQLSERVERNAME\INSTANCENAME when using an external SQL Server instance
44-
45- # Run the scheduled task immediately
46- Start-ScheduledTask -TaskName "WSUS Update Operating Systems"
21+ # Update PowerShellGet for Windows PowerShell 5.1 - https://learn.microsoft.com/en-us/powershell/gallery/powershellget/update-powershell-51?view=powershellget-3.x
22+ Install-Module -Name PowerShellGet -AllowClobber -Force
23+ # (When prompted if you want PowerShellGet to install and import the NuGet provider, respond with 'Y')
24+
25+ # Install latest version of SQLServer module - https://learn.microsoft.com/en-us/powershell/sql-server/download-sql-server-ps-module?view=sqlserver-ps
26+ Install-Module -Name SqlServer
27+ # (When prompted if you want to install the modules from 'PSGallery', respond with 'Y')
28+
29+ # Change to Update Services installation directory
30+ Set-Location "$env:ProgramFiles\Update Services"
31+
32+ # Download latest version of the script to "%ProgramFiles%\Update Services\Update-WSUSComputerOperatingSystems.ps1"
33+ Invoke-WebRequest -Uri "https://raw.githubusercontent.com/Borgquite/Update-WSUSComputerOperatingSystems/refs/heads/main/Update-WSUSComputerOperatingSystems.ps1" -OutFile Update-WSUSComputerOperatingSystems.ps1
34+
35+ # Create a new scheduled task to run at midnight daily for up to 2 hours on a local Windows Internal Database instance
36+ Register-ScheduledTask -TaskName "WSUS Update Operating Systems" `
37+ -User 'SYSTEM' `
38+ -Action (New-ScheduledTaskAction -Execute '%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe' `
39+ -Argument '-NoProfile -NonInteractive -ExecutionPolicy Bypass -File "%ProgramFiles%\Update Services\Update-WSUSComputerOperatingSystems.ps1" -SQLServerInstance "\\.\pipe\MICROSOFT##WID\tsql\query" -Encrypt Optional' `
40+ -WorkingDirectory '%ProgramFiles%\Update Services') `
41+ -Settings (New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan -Hours 2)) `
42+ -Trigger (New-ScheduledTaskTrigger -At "00:00:00" -Daily)
43+ # Update \\.\pipe\MICROSOFT##WID\tsql\query in the above command to SQLSERVERNAME\INSTANCENAME when using an external SQL Server instance
44+
45+ # Run the scheduled task immediately
46+ Start-ScheduledTask -TaskName "WSUS Update Operating Systems"
47+ ```
0 commit comments