Windows 10: Trigger detecting updates from command line

Hi,

since Windows 10 the command wuauclt /detectnow does not work anymore.

You can simply use the Comject Object Microsoft.Update.AutoUpdate within powershell (in evelated/administrator mode) to trigger Windows Update for detecting new updates.

(new-object -Comobject Microsoft.Update.AutoUpdate).detectnow()

To Install all downloaded Updates and restart the computer if requiered:

$oInstaller=(New-Object -ComObject Microsoft.Update.Session).CreateUpdateInstaller()
$aUpdates=New-Object -ComObject Microsoft.Update.UpdateColl
((New-Object -ComObject Microsoft.Update.Session).CreateupdateSearcher().Search("IsAssigned=1 and IsHidden=0 and IsInstalled=0 and Type='Software'")).Updates|%{
	if(!$_.EulaAccepted){$_.EulaAccepted=$true}
	[void]$aUpdates.Add($_)
}
$oInstaller.ForceQuiet=$true
$oInstaller.Updates=$aUpdates
if($oInstaller.Updates.count -ge 1){
  write-host "Installing " $oInstaller.Updates.count "Updates"
  if($oInstaller.Install().RebootRequired){Restart-Computer}
} else {
  write-host "No updates detected"
}

Or use the Windows Update Powershell Module which provides a set of command-lets for handling windows updates.

Newer Version of Windows 10 uses the usoclient command line utility. There are 4 options

usoclient StartScan
usoclient StartDownload
usoclient StartInstall
usoclient RestartDevice

Michael

Advertisment to support michlstechblog.info

One thought on “Windows 10: Trigger detecting updates from command line”

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.