A complete step-by-step standard operating procedure for installing and scheduling Windows security updates using the PSWindowsUpdate PowerShell module, designed for sysadmins managing enterprise endpoints.
Open PowerShell as an Administrator (right-click the Start menu โ Windows PowerShell (Admin)).
Then run the following command to install the PSWindowsUpdate module from the PowerShell Gallery:
Install-Module -Name PSWindowsUpdate -Force -AllowClobber
If prompted to install the NuGet provider, type Y and press Enter.
The -Force flag bypasses confirmation prompts, and -AllowClobber allows overwriting
existing commands from other modules if any conflict arises.
After installation, import the module into your current PowerShell session so its cmdlets become available. This step is required every time you start a new session unless you have auto-import enabled via your profile.
Import-Module PSWindowsUpdate
Get-Command -Module PSWindowsUpdate to confirm the module loaded correctly and to see all available cmdlets.
Use Get-WindowsUpdate to query Windows Update for available patches.
You can retrieve all pending updates or filter specifically for security-classified updates.
List all available updates:
Get-WindowsUpdate
Filter for Security Updates only:
Get-WindowsUpdate -Classification SecurityUpdates
The output will list all updates along with their KB article numbers, titles, sizes, and classification. Review the list before proceeding to installation to understand what changes will be applied.
Once you have reviewed the available security updates, use Install-WindowsUpdate to apply them.
The command below filters for security updates, auto-accepts all prompts, and reboots the system if required.
-AutoReboot flag will restart the machine without additional prompts if any update requires it.
Ensure all critical work is saved and users are notified before running this in a production environment.
Install-WindowsUpdate -Classification SecurityUpdates -AcceptAll -AutoReboot
| Parameter | Description |
|---|---|
| -Classification SecurityUpdates | Targets only updates classified as security patches, excluding optional/driver updates. |
| -AcceptAll | Automatically accepts all update license agreements and installation prompts without manual input. |
| -AutoReboot | Triggers an automatic system reboot after installation if any update requires it. |
After the installation completes (and the system reboots if applicable), run the following command to confirm the security updates were successfully installed:
Get-WindowsUpdate -Install
This command displays a history of all installed updates. Review the list to confirm the expected KB articles are present. You can cross-reference with Microsoft's Security Update Guide using the KB numbers shown.
For endpoints that require recurring automated patching, you can register a Windows Scheduled Task that runs the update installer on a defined schedule. The example below configures a daily run at 3:00 AM.
Register-ScheduledTask \ -Action (New-ScheduledTaskAction \ -Execute 'powershell.exe' \ -Argument 'Install-WindowsUpdate -AcceptAll -AutoReboot') \ -Trigger (New-ScheduledTaskTrigger -Daily -At 3am) \ -TaskName "AutoWindowsUpdate" \ -Description "Automatically installs Windows security updates."
| Component | Purpose |
|---|---|
| Register-ScheduledTask | Registers a new task in Windows Task Scheduler under the current user or SYSTEM context. |
| New-ScheduledTaskAction | Defines the executable and arguments to run. In this case, PowerShell with the update command. |
| New-ScheduledTaskTrigger -Daily -At 3am | Sets the task to fire every day at 3:00 AM local time. |
| -TaskName | A human-readable label visible in Task Scheduler for easy identification and auditing. |
Official documentation and community resources for deeper exploration of PowerShell-based patch management.