The Easiest way to automatically update windows machines using PowerShell & RMM Solutions

💡 This scripts is highly recommended with RMM Solutions (NinjaOne, Datto, N-able, ManageEngine…etc) to be executed remotely.

1 – Update User machine without Reboot :

This script can be used directly on users production machines. it allows updates to run in the background without interrupting the user. Once updates have been downloaded and installed, they are automatically applied the next time the system is rebooted. This approach ensures that Windows machines remain up-to-date while minimizing the impact on user productivity, avoiding unnecessary interruptions to their work.

# Set Execution Policy
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force

# Test if module PSWindowsUpdate is installed, if not install it
if (-not (Get-Module -ListAvailable -Name PSWindowsUpdate)) 
{
  Install-PackageProvider -Name NuGet -Force
  Install-Module -Name PSWindowsUpdate -Confirm:$false -Force   
}

# Import PSWindowsUpdate module
Import-Module PSWindowsUpdate

# Start updating windows without reboot
Get-WindowsUpdate -AcceptAll -Install -IgnoreReboot

2 – Update User machine with Reboot :

This script can be run on spare machines, so you only need one click to install updates and restart the machine.

# Set Execution Policy
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force -Scope Process

# Test if module PSWindowsUpdate is installed, if not install it
if (-not (Get-Module -ListAvailable -Name PSWindowsUpdate -ErrorAction SilentlyContinue)) 
{
    Install-PackageProvider -Name NuGet -Force
    Install-Module -Name PSWindowsUpdate -Force -Confirm:$false
}

# Import PSWindowsUpdate module
Import-Module PSWindowsUpdate

# Start updating windows with reboot
Get-WindowsUpdate -AcceptAll -Install -AutoReboot

Thanks

Aymen EL JAZIRI (Microsoft MVP)
Aymen EL JAZIRI (Microsoft MVP)

Hi, I’m Aymen El Jaziri , a passionate System Administrator and Microsoft MVP, with years of hands-on experience in managing and securing modern IT infrastructures.
This blog is where I share technical guides, automation scripts, product reviews, and real-world solutions that help IT professionals simplify their day-to-day work and stay ahead in a fast-evolving cloud ecosystem.
Whether you’re here to troubleshoot an issue, improve your automation game, or learn new best practices , welcome in my blog !
Let’s build a stronger, smarter IT community together.
Feel free to connect with me on LinkedIn for more content, discussions, or collaboration opportunities.

Thanks

Aymen

Articles: 154