SOLVED: SIMPLE PowerShell Script To Download & Install Windows Updates Then Reboot If Necessary

I have been trying to get a simple CMD script or PowerShell or even a utility to get Windows 10 to download and install Windows Updates for about a year.  It has not gone well.

Note that Angus Briggs at PDQ support told me about a very simple PowerShell command that will kick off Windows Update and download the files, but it will not install them or check for a reboot:

(New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()

Also note that following Windows Update command everyone used to use, no longer works in Windows 10:windows-update-script-download-install-reboot

wuauclt.exe /detectnow

So without further adieu, the SIMPLE PowerShell script that installs all of the necessary parts (except PowerShell v5 because it is built into Windows 10 1703 and newer so you likely already have it), and then downloads and installs Windows Updates, then reboots if necessary is:

# By Ian Matthews with the help of many
# Last Updated July 28 2017

# Requires PowerShell 5.0 or newer
# Apparently NUGET is required for the PSWINDOWSUPDATE module
Install-PackageProvider NuGet -Force
Import-PackageProvider NuGet -Force

# Apparentely PSWindowsUpdate module comes from the PSGallery and needs to be trusted
# See
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted

# Now actually do the update and reboot if necessary
Install-Module PSWindowsUpdate
Get-Command –module PSWindowsUpdate
Add-WUServiceManager -ServiceID 7971f918-a847-4430-9279-4a52d1efe18d -Confirm:$false
Get-WUInstall –MicrosoftUpdate –AcceptAll –AutoReboot

This script works very well if you copy and paste it directly into a PDQ Deploy PowerShell window.


  1. Avatar
    Chris November 7, 2018 at 10:06 am

    When trying to run the Add WUServiceManager -ServiceID command as above in your example I get the following error:

    Add-WUServiceManager : SATS: Unknown failure. Try debug.
    At line:1 char:1
    + Add-WUServiceManager -ServiceID 7971f918-a847-4430-9279-4a52d1efe18d …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : CloseError: (:) [Add-WUServiceManager], Exception
    + FullyQualifiedErrorId : AddService2,PSWindowsUpdate.AddWUServiceManager

  2. Avatar
    sebus April 19, 2018 at 12:10 pm

    You ought to use
    Install-WindowsUpdate –AcceptAll –AutoReboot

Questions or Comments?