← script library

Automate Windows Update Management with PowerShell

Software DeploymentDecember 24, 2024

In this post, we will share a PowerShell script that automates the process of managing Windows Updates on your system. Keeping your Windows operating system up-to-date is essential for security and performance. This script allows administrators to check for available updates, install them, and even restart the system if necessary, streamlining the update process across multiple machines. Here is the PowerShell script for managing Windows Updates:

powershell
# Ensure the PSWindowsUpdate module is available
Install-Module -Name PSWindowsUpdate -Force -Scope CurrentUser
# Import the module
Import-Module PSWindowsUpdate
# Check for available updates
$updates = Get-WindowsUpdate
# Show available updates
if ($updates) {
    Write-Host "The following updates are available:" -ForegroundColor Yellow
    $updates | Format-Table -Property KB, Title
    # Install the updates
    Write-Host "Installing updates..."
    $updates | Install-WindowsUpdate -AcceptAll -AutoReboot
} else {
    Write-Host "No updates are available at this time." -ForegroundColor Green
}

Run it across your fleet

This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.

Ready when you are.

Try ServerEngine free for 7 days.