Situatie
Solutie
Part 1: Create a Patch-Automation PowerShell Script
Step 1 — Open PowerShell ISE or VS Code
You’ll write a script that:
-
Checks for available Windows updates
-
Installs them
-
Generates a log file
Step 2 — Use the Windows Update Module
Install the module (only needed once):
Step 3 — Create an Update Script
Save this as AutoPatcher.ps1:
Step 4 — Test the Script
Run:
Confirm it:
-
Produces a log file
-
Installs updates normally
Part 2: Automate Using Task Scheduler
Step 1 — Open Task Scheduler
Create a Basic Task → Name it “Auto Patch”
Step 2 — Set the Trigger
Choose:
-
Weekly (recommended)
-
During off hours (e.g., 3:00 AM)
Step 3 — Set the Action
Action → Start a Program
Program/Script:
Add arguments:
Step 4 — Run With Highest Privileges
Check Run whether user is logged on or not and Run with highest privileges.
Verification
After the scheduled time:
-
Check
C:\Logs\for patch logs. -
Confirm reboot behavior is acceptable.
-
Review Event Viewer → Task Scheduler.
Optional Enhancements
-
Email notifications using
Send-MailMessage -
Push logs to a central SIEM
-
Add software updates (Chrome, Java, etc.) with Chocolatey.
Leave A Comment?