How to Update Windows 10 from CMD or PowerShell

Updating an operating system, such as Windows 10, is very important. Thanks to the patches we will be able to update our PC, correct all kinds of errors and failures that can give us problems on a day-to-day basis, and even cover possible security gaps that may pose a danger when connecting to the Internet. The default way to update Windows 10 is to do it from Windows Update . However, there are other tricks that allow us to download and install these updates. And one of the most interesting is to update the PC from CMD or PowerShell.

Although Windows is intended to be used in graphical mode, and having to execute fewer commands the better, there are times when graphical environments do not work quite well. In addition, there are users who like to automate certain tasks, and execute certain actions through scripts, for whom graphical interfaces fall short. In those cases, what we must do is look for an alternative that allows us to carry out these tasks. And the most common is to resort to CMD and PowerShell.

 Update Windows 10 from CMD or PowerShell

CMD is the Windows console inherited from MS-DOS. From it, you can run basic programs and run the typical commands from the pre-Windows era to control the system and certain functions of the operating system. On the other hand, PowerShell is Microsoft‘s advanced console that allows us to easily manage almost any aspect of the operating system, a much more advanced console with which to do practically everything.

Of course, both tools can be used to easily download and install the latest Windows patches. Here we explain how.

Update Windows 10 from CMD

CMD is the most basic console in Windows 10. And, although certain advanced tasks cannot be performed from it, Microsoft has a specific command to analyze the system, check for updates and download them very quickly.

In order to use these commands, the first thing we must do is run CMD, with Administrator permissions , from the Windows 10 browser. It is important to run it as administrator, since otherwise we will not be able to use this tool.

Abrir CMD

The commands that we must execute in a Windows 10 CMD window to update the system are:

  • Usage Client StartScan (to start scanning the system)
  • UsoClient StartDownload (to start downloading patches)
  • UsoClient StartInstall (to start installing downloaded patches)
  • UsoClient RefreshSettings (updates if changes are available)
  • UsoClient RestartDevice (restart the computer to finish the installation)

In addition, we can also replace the previous commands with the following one, since it will analyze the system, download the available patches and install them on the PC:

  • Use Client ScanInstallWait

Each of these commands must be executed in order and wait for its process to finish before executing the next one. These commands are designed especially for advanced users, but they are also the ones that Windows itself uses to automate updates as scheduled tasks, so there will be no problems when using them.

Update previous versions

The commands that we have just seen only work in Windows 10. Therefore, if we have an older operating system, such as Windows 7 or 8.1, we will not be able to use them. For these systems we will have to resort to other alternative commands that allow us to do, broadly, the same.

For previous versions of the operating system, the commands that we must execute are the following:

  • wuauclt / detectnow
  • wuauclt / updatenow
  • wuauclt / detectnow / updatenow

Of course, we will have to execute these commands in sequential order, from first to last. This way the system will look for the updates, download them and, finally, install them. When it is finished we may have to restart the computer manually so that the configurations are completed since, if we do not do it, we may have problems.

Update Windows using PowerShell

If what we want is to have more control over the process, create scripts easily, or simply be a “poweruser”, then we can do the same using the PowerShell console directly. As with CMD, the first thing we need to do is make sure to run PowerShell with Administrator permissions so that we can use its full potential without problems.

Abrir PowerShell con permisos de Admin

Once we have it open, the first thing we will have to do is install the corresponding module. To do this, we will execute the following command in the console: ” Install-Module PSWindowsUpdate “. To install the module we may have to confirm a couple of questions to download the dependencies that are necessary. We must answer “Yes” to all the questions so that everything necessary can be downloaded and installed.

Once the installation is finished, all we have to do to update Windows is run ” Get-WindowsUpdate “. This command is only in charge of searching for updates and showing us a list of all available ones.

In case of having updates, we can install all of them using the “-Install” parameter, or execute the following command indicating the KB of the updates we want to install:

Get-WindowsUpdate -KBArticleID KB2267602, KB4533002 -Install

When the process is finished we will have our Windows updated. Of course, we may need to restart the computer at the end for all the changes to take effect.

From PowerShell we can also execute the CMD “UsoClient” commands, since they are compatible.

Enable script execution

For security reasons, Windows 10 blocks the execution of scripts by default. In case this happens, when trying to execute the previous command, we will see an error message that will indicate that the corresponding module could not be loaded. If we execute the ” Get-ExecutionPolicy ” command we can see how PowerShell returns a “Restricted”.

To be able to execute these commands without problems, what we must do is change the Windows 10 security policy from “restricted” to “without restrictions”. And we can easily do this by simply executing the ” Set-ExecutionPolicy Unrestricted ” command.

Quitar restricción scripts PowerShell

Once done, this command should work without problems. And all the others that we are going to run from the advanced Windows console. Of course, we must bear in mind that this change drastically reduces the security of our Windows 10. We must be careful with what we download and execute since Microsoft will not block the scripts that can endanger our PC.