Share via


Windows 10 - Windows Update - Command Line

Question

Tuesday, June 20, 2017 11:57 AM | 1 vote

Hello everybody,

i want to install updates remotely on the Client Win10 1703.

with this command the Client only search for updates, but don`t install:

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

-enter-pssession %Client%

-search for updates: (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()

-and install? does exist a command for this?

All replies (5)

Tuesday, June 20, 2017 2:02 PM

Here's a powershell module that does it:  https://gallery.technet.microsoft.com/scriptcenter/2d191bcd-3308-4edd-9de2-88dff796b0bc

EDIT:

# check
 get-wulist -category 'critical update','security update','update rollup' -verbose

# update
get-wuinstall -category 'critical update','security update','update rollup' -acceptall -verbose -ignorereboot

Wednesday, June 21, 2017 6:21 AM

Hi -Paz-,

In addition, this powershell script will give you the ability to install windows updates on a remote computer. The script will remotely create a scheduled task on the given computer with the needed powershell cmdlets to: 1. Search for updates 2. Download updates 3. Install updates.

https://gallery.technet.microsoft.com/scriptcenter/Force-Install-Updates-on-ef821f9a

Hope it will be helpful to you

Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected].


Wednesday, December 19, 2018 9:48 AM | 3 votes

There is no standard command for that - but there is a tool that wraps the Windows Update API into a neat command line tool with a few options - try WuInstall to run windows update from command line - in combination with psExec it can be a very powerful tool

Search (without any additional options) goes like this:

wuinstall /search

Install:

wuinstall /install


Wednesday, July 10, 2019 4:41 PM

Hi,

The following powershell script will check for updates and install them on a remote computer.  The key here is the following command: 

%windir%\explorer.exe ms-settings:windowsupdate-action

That command has to start first to bring up the Windows Update GUI (Win 10) otherwise the commands that follow after that one will fail.

$Computer = Read-Host 'ENTER PC NAME'
$User = Read-Host -Prompt 'ENTER USER NAME'

# Collects the correct logged in session.  Script will fail without this on a remote pc
$results = psexec \$Computer query session
$id = $results | Select-String "$User\s+(\w+)" |
                 Foreach {$_.Matches[0].Groups[1].Value}

# Begins Update detection and install
PSEXEC -s -i $id \$Computer cmd /c %windir%\explorer.exe ms-settings:windowsupdate-action | PowerShell.exe (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()

# A few things you may want to add/alter in script:

# Ability to restart PC immediately after updates install

# Ability to install updates remotely with no user logged in

Hope that helps and I welcome any corrections.


Tuesday, September 10, 2019 8:40 AM

is it possible to run on al list of computers?

and  to query on console session?