PSWindowsUpdate module and applies all available Windows updates. Supports optional automatic reboot when kernel or driver updates require it.
Prerequisites
The script must be run in an elevated (Administrator) PowerShell session. Right-click PowerShell and select Run as Administrator, or open Windows Terminal as Administrator.The Script
windows-update.ps1
Usage
Scheduling with Task Scheduler
To run updates on a schedule:- Open Task Scheduler (
taskschd.msc) - Create a new task with Run with highest privileges checked
- Set the trigger to your preferred schedule (e.g., weekly on Sundays at 3:00 AM)
- Set the action to:
- Program:
powershell.exe - Arguments:
-ExecutionPolicy Bypass -File "C:\Scripts\windows-update.ps1"
- Program:
-AutoReboot to the arguments if you want the server to reboot automatically after updates.
What PSWindowsUpdate Provides
ThePSWindowsUpdate Module is a widely used community module that wraps the Windows Update Agent API. Key commands:
| Command | Description |
|---|---|
Get-WindowsUpdate | List available updates without installing |
Install-WindowsUpdate -AcceptAll | Download and install all available updates |
Get-WUHistory | View update installation history |
Get-WURebootStatus | Check if a reboot is pending |