PowerShell Reference

A growing library of PowerShell tools and patterns I've put together as a sysadmin. Public and open-source for anyone who wants to learn, copy, or contribute.

View on GitHub

🪟 Windows Update with PowerShell

This guide provides a universal approach to managing Windows Updates using PowerShell—compatible with both client endpoints and servers.


📦 Install PSWindowsUpdate Module

Most advanced update tasks require the PSWindowsUpdate module, which works on both Windows clients and servers.

Install-PackageProvider -Name NuGet -Force
Install-Module -Name PSWindowsUpdate -Force
Import-Module PSWindowsUpdate

If prompted to trust the repository, type Y.


🔍 Check for Available Updates

Get-WindowsUpdate

This checks for pending updates from Windows Update or WSUS depending on system configuration.


📥 Install Updates

Install-WindowsUpdate -AcceptAll -AutoReboot

For interactive use without auto reboot:

Install-WindowsUpdate -AcceptAll

🔄 Check & Install in One Command

Get-WindowsUpdate -Install -AcceptAll -AutoReboot

📋 List Installed Updates

Built-in alternative (does not require module):

Get-HotFix

❌ Hide a Specific Update

Hide-WindowsUpdate -KBArticleID "KB5009543" -Hide

🧪 Optional: Enable Script Execution

Required to run remote or downloaded scripts:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

🕒 Schedule Automatic Update Task

Example: Run daily at 2 AM:

$Trigger = New-ScheduledTaskTrigger -Daily -At 2am
$Action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "Install-WindowsUpdate -AcceptAll -AutoReboot"
Register-ScheduledTask -TaskName "AutoWindowsUpdate" -Trigger $Trigger -Action $Action -RunLevel Highest -User "SYSTEM"

🧠 Notes


🔗 References