Wsus_Package_Publisher icon indicating copy to clipboard operation
Wsus_Package_Publisher copied to clipboard

Enhancements request: Update "Detect Now" command for Windows 10

Open StyleTec opened this issue 6 years ago • 1 comments

From Windows 10 on, the "wuauclt /detectnow" command is no longer working and replaced by "usoclient StartScan". Could you please change the behaviour for Windows 10 clients. The metadata which version the client has, should be available from WSUS database.

StyleTec avatar Jun 06 '19 12:06 StyleTec

On our Windows 10 clients be use psexec and powershell scripts below:

To detect:

  • PSEXEC -s \ComputerName powershell.exe -ExecutionPolicy Bypass -File WSUS-Detect.ps1

To install:

  • PSEXEC -s \ComputerName powershell.exe -ExecutionPolicy Bypass -File WSUS-Install.ps1

WSUS-Detect.ps1

$Session = New-Object -Com Microsoft.Update.Session
$Searcher = $Session.CreateUpdateSearcher()
$SearchResult = $Searcher.Search("IsInstalled=0").Updates
Write-Output $SearchResult.Count

WSUS-Install.ps1

$Session = New-Object -Com Microsoft.Update.Session
$Searcher = $Session.CreateUpdateSearcher()
$SearchResult = $Searcher.Search("IsInstalled=0").Updates
try { 
  $Downloader = $Session.CreateUpdateDownloader()
  $Downloader.Updates = $SearchResult
  $Downloader.Download()

  $Installer = $Session.CreateUpdateInstaller()
  $Installer.Updates = $SearchResult
  $InstallResult = $Installer.Install()
} catch {
  if($_.Exception.HResult -eq -2145124330) {
    Write-Host "There is either an update in progress or there is a pending reboot blocking the install."
  } else { 
    Write-Host "There is was an error trying to install an update."
  }
  Continue
}

This might help.

tb-mtg avatar May 12 '21 23:05 tb-mtg