How To Run Windows Update From Command Line

Installing Windows updates keeps your system safe and stable. They include new features, security patch updates, and fixes for your OS. There are many ways to check and install pending Windows updates. Learn all of them in this ost, and troubleshoot any issues that you may come across.

Install Module PSWindowsUpdate

In Microsoft Windows 10, Windows Update can be found in Settings >> Update & Security >> Windows Update, while in Windows 11, it can be found in Settings >> Windows Update.

Normally, Windows Update keeps on running in the background and will install new updates automatically.

Windows Update checks for new updates randomly every 22 hours. The reason behind the random check is that if all the systems in the world start checking for updates at the same time, this would put an extreme load on Microsoft servers. That’s why Microsoft came up with the idea of checking for updates randomly every day.

You can also run Windows Update manually to check for new updates at any time. Here are three ways to check for new Windows updates.

Force Windows Update Check using Run Command Box

I found out that the easiest way to force a Windows update check is to use a command in the Run dialog box. There are other commands from CMD and PowerShell as well, but let’s start with the easiest way to do it.

  1. Open the Run Command box (Windows key + R).

  2. Run the following command:

    control update
    control update
    Check Windows update from the Run Command box

This will trigger the Windows Update graphical user interface which will start checking for new updates. This method works on all versions of Windows including Windows 10 and Windows 11.

There is another command that will trigger the same effect but only works in Windows 10 and 11:

ms-settings:windowsupdate
Trigger Windows Update from Settings app
Trigger Windows Update from Settings app

Run Windows Update from PowerShell (Command-line)

There is no official Windows PowerShell module for Windows Update. However, you can use “PSWindowsUpdate.” PSWindowsUpdate is a third-party module that can be used to configure Windows updates in Windows.

This module is not installed in Windows by default but you can download it from the PowerShell gallery, and install and run the module to check for new updates.

Here are the three steps to run Windows Update through PowerShell:

  1. Run the following command to install PSWindowsUpdate:

    Install-Module PSWindowsUpdate
    Install Module PSWindowsUpdate
    Install PSWindowsUpdate module
  2. Now check for available updates by running this cmdlet:

    Get-WindowsUpdate
    Get WindowsUpdate
    Check for available Windows updates
  3. Now install these updates using this cmdlet:

    Install-WindowsUpdate
    Install WindowsUpdate
    Install available Windows updates

The above-mentioned commands will only install the Windows updates. If you want to update other Microsoft products as well, you’ll need to enable the Microsoft Update Service as well. It’s pretty easy to enable it using PowerShell:

Add-WUServiceManager -MicrosoftUpdate

If you want to automatically restart your computer after installing all the updates, you can run the following command instead:

Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -AutoReboot

Deploy Updates on Remote Computers

The PSWindowsUpdate PowerShell module can also be used to deploy Windows updates on remote computers. There are two commands involved in this process:

  1. Create a list of computers and pass the list as a variable string using the computer names:

    $computer = "comp1, comp2, comp3"

    You can add more computers to the string separated by commas. Replace “compX” with the name of each computer.

  2. Run the following command to start checking for Windows updates on remote computers:

    Invoke-WUJob -ComputerName $computer -Script {ipmo PSWindowsUpdate; Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -AutoReboot} -RunNow -Confirm:$false | Out-File "\server\share\logs\$computer-$(Get-Date -f yyyy-MM-dd)-MSUpdates.log" -Force

Install Specific Updates Only

If you already know the article KB no. of the specific update you want to install, you can run the following command to install that particular update(s) only:

Get-WindowsUpdate - KBArticleID "KB5002324", "KB5002325" -Install

Replace the KB number with the one you want to install.

Prevent Specific Windows Updates from Installing

You can prevent specific updates from installing on your computer by replacing the KB numbers in the following command in PowerShell:

Install-WindowsUpdate -NotKBArticle "KB5002324, KB5002325" -AcceptAll

Run Windows Update from Command Prompt (Command-Line)

Windows Update can also be run through legacy Command Prompt to get the latest updates. The only limitation of running Windows Update through the CMD is that it won’t show any progress. Only results are shown when the process is complete. Let’s see how to run it:

RestartDeviceRestart Windows after updates are installed

ScanInstallWait – Check for updates, download available updates, and install them

  1. Launch Command Prompt with administrative privileges.

  2. Run the following command to check for new updates:

    wuauclt /detectnow
  3. Run the following command to install new updates:

    wuauclt /updatenow

Since the command prompt does not show any progress, a better approach would be to check and install updates at the same time. Here’s the command for this:

wuauclt /detectnow /updatenow

The above-mentioned command will work in all versions of Windows, including Windows 7 and Windows Server 2008 R2. But if you are using Windows 10 or Windows Server 2016, you can use the “UsoClient” command which has more options than “wuauclt.” You can run UsoClient with the following switches:

  • StartScan – Start checking for updates
  • StartDownload – Start downloading updates
  • StartInstall – Start installing downloaded updates

Check for Windows Updates using Windows Settings

To check for new updates and configure your Windows Update settings, follow the steps below:

  1. Navigate to:

    • In Windows 11:

      Settings app >> Windows Update
    • In Windows 10:

      Settings app >> Update & Security >> Windows Update
  2. Click “Check for updates.”

    check for updates Windows 11
    Check for pending updates

How to Force Windows Update to Download Already Downloaded Updates

There will be times when the updates become corrupted or for other reasons, you just don’t want to install the downloaded updates. In that situation, you can easily delete the already-downloaded updates, which will force Windows Update to run again and check for and download the updates again.

The only caveat in this situation is that the update must not have been installed on your computer. If the update is already installed, Windows will detect it as installed and will not download it again. In that case, you will need to uninstall the update first and then force Windows Update to run again.

If you want to force Windows Update to re-download all the updates again, you can do this using the steps below.

  1. Navigate to the following directory using File Explorer:

    C:\Windows\SoftwareDistribution\Download

    This folder contains all the Windows update files that Windows OS is currently downloading or recently downloaded and installed.

  2. Select and delete all the files from the “Download” folder.

    Delete all files in Download folder
    Delete all files in the “Download” folder
  3. Run Windows Update again using the above-mentioned methods.

    This will force Windows Update to check for the same updates and download them again. The download and install process for new updates is completely automated. You don’t need to do anything during the download and installation process.

Manage Windows Updates using Wuinstall Command Line Tool

Using WuInstall, IT Administrators can automate Windows updates. Wuinstall can be used to enforce Windows Updates inquiries, downloads, and installations at times when they deem them appropriate, enabling them to make the entire update process more controlled and user-friendly.

WuInstall is a strong and flexible system management tool that can be used in a WSUS-based or standalone environment. To download the latest updates using Wuinstall, you will need to download and install Wuinstall first. Follow the steps below:

  1. Go to http://www.wuinstall.com/ and install the latest free version of Wuinstall on your computer.

  2. Open an elevated Command Prompt.

  3. Run the following cmdlet to search for the latest available Windows updates:

    wuinstall /search

    This will not only look for new updates but will also list them in the command window.

  4. To download the updates, run the following command:

    wuinstall /download

    This will download all the available updates from Microsoft servers.

  5. To install the updates, run the following command:

    wuinstall /install

There are a few more switches that you can use with the install command:

  • /quiet – will install updates without showing anything.
  • /disableprompt – Disable any input from Windows.
  • /autoaccepteula –  Auto-accept any agreement during the update installation.
  • /rebootcycle – Install updates on the next computer reboot.

How to Fix Corrupted Windows Update

Sometimes Windows Update files get corrupted and the user is not able to download the files again or install the corrupted update files. In that case, we need to run a DISM command to fix the corrupted Windows Update. Here are the steps:

  1. Launch the Command Prompt.

  2. Run the following cmdlet:

    dism.exe /Online /Cleanup-image /Restorehealth

After successfully running this command, try force downloading the updates again and the Windows Update should start working again.

Other things you can do with Windows Update:

Disable or bypass pending updates on Windows 10 (and Windows 11)

How to prevent a specific update from installing while allowing all others

How to view and save a list of installed updates in Windows 10 (and Windows 11)

View updates sizes in Windows 10 (and Windows 11)

Download any Windows 10 cumulative update

How to disable automatic restart after installing the updates

How to add update packages to Windows 10 ISO image

How to disable automatic updates

How to limit Windows Update bandwidth usage

How to install updates offline using CAB and MSU files

Hopefully, this will be useful in situations where you want to automate certain Windows functions. What other purposes do you want to use command line options to run Windows Update?

Also see:

Usman Khurshid is a seasoned IT Pro with over 15 years of experience in the IT industry. He has experience in everything from IT support, helpdesk, sysadmin, network admin, and cloud computing. He is also certified in Microsoft Technologies (MCTS and MCSA) and also Cisco Certified Professional in Routing and Switching.

15 Comments

  1. Thank you Usman! Wow Microsoft has a new cli USOClient.exe awesome!

  2. T. Joy Lee says:

    Thank you. Refurbished machine – needed to update in order to move from other machine to “new to me” machine after just getting ti to cooperate with the network. I have never run across a machine that would not update before. The cmd options did not work, but the PS option was exactly what I needed. Added to my bag of tricks. Thank you so much!!

  3. usoclient.exe /StartScan does not update the shown ‘Last checked date’ shown in the GUI on a Windows Server 2016 or 2019.

  4. PS C:\> Start-Service wuauserv -Verbose
    PS C:\> $updateSession = new-object -com “Microsoft.Update.Session”;$updates=$updateSession.CreateupdateSearcher().Search($criteria).Updates
    PS C:\> (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()

    This is work on a Windows 10 – the Last checked time is updated in the GUI
    BUT it’s not workting om Windows 2016 or 2019

    Any know of a way to make this work on a Server 2016 ??

    1. I don’t get any of these from article to work. Not even: Start-Service wuauserv -Verbose

      PS C:\WINDOWS\system32> Start-Service wuauserv -Verbose
      VERBOSE: Performing the operation “Start-Service” on target “wuauserv (wuauserv)”.
      Start-Service : Failed to start service ‘wuauserv (wuauserv)’.
      At line:1 char:1
      + Start-Service wuauserv -Verbose
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : OpenError: (System.ServiceProcess.ServiceController:ServiceController) [Start-Service],
      ServiceCommandException
      + FullyQualifiedErrorId : StartServiceFailed,Microsoft.PowerShell.Commands.StartServiceCommand

      Halp?

  5. usoclient StartScan does NOT make any changes to the Last checked date shown in the GUI
    Neither does the Powershell command Get-WindowsUpdate

    In previous Windows I had to updating the Last checked value in registry after performing a scan using the API (as they dont). But MS has moved the location to an unknown place i 2016 and 2019.

    Anyone who knows how to update the “Last checked date” from CMD or API ???

    1. Function Force-WSUSCheckin($Computer)
      {
      Invoke-Command -computername $Computer -scriptblock { Start-Service wuauserv -Verbose }
      # Have to use psexec with the -s parameter as otherwise we receive an “Access denied” message loading the comobject
      $Cmd = ‘$updateSession = new-object -com “Microsoft.Update.Session”;$updates=$updateSession.CreateupdateSearcher().Search($criteria).Updates’
      & c:\bin\psexec.exe -s \\$Computer powershell.exe -command $Cmd
      Write-host “Waiting 10 seconds for SyncUpdates webservice to complete to add to the wuauserv queue so that it can be reported on”
      Start-sleep -seconds 10
      Invoke-Command -computername $Computer -scriptblock
      {
      # Now that the system is told it CAN report in, run every permutation of commands to actually trigger the report in operation
      wuauclt /detectnow
      (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()
      wuauclt /reportnow
      c:\windows\system32\UsoClient.exe startscan
      }
      }

  6. It doesn’t work.

    Get-WindowsUpdate: The ‘Get-WindowsUpdate’ command was found in the module ‘PSWindowsUpdate’, but the module could
    not be loaded. For more information, run ‘Import-Module PSWindowsUpdate’.
    At line:1 char:1
    + Get-WindowsUpdate
    + ~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Get-WindowsUpdate:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

    1. To remedy that, please try the following:
      1. Run Set-ExecutionPolicy -ExecutionPolicy Unrestricted
      2. Run Import-Module PSWindowsUpdate
      3. Try running Get-WindowsUpdate again.
      This worked for me.

  7. wuauclt is no longer available with Windows 10.
    You can use usoclient.exe instead.
    Parameters are /StartScan, /StartDownload, /StartInstall

    1. “wuauclt is no longer available with Windows 10”

      That’s not true at all. I use it all the time to have machines check in.

      $updateSession = new-object -com “Microsoft.Update.Session”; $updates = $updateSession.CreateupdateSearcher().Search($criteria).Updates

      wuauclt /reportnow

      Works 100% of the time. Windows 10 22H2 and Server 2022.

      UsoClient on the other hand, no longer works. MS did something to restrict access.

Leave a Reply

Your email address will not be published. Required fields are marked *