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.

Michael

Advertisment to support michlstechblog.info

Add a comment »One comment to this article

  1. Fantastic !! 🙂 thanks

    Reply

Time limit is exhausted. Please reload CAPTCHA.

Original Theme by Schiy · Powered by WordPress