Advertisement
J2897

Update Windows

Nov 25th, 2024
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Start scanning for updates
  2. Write-Host "Scanning for updates..."
  3. usoclient StartScan
  4.  
  5. # Wait for scan to complete (optional, adjust timing as needed)
  6. Start-Sleep -Seconds 10
  7.  
  8. # Check for pending updates using WMI
  9. $UpdatesPending = Get-WmiObject -Namespace "Root\cimv2" -Query "Select * from Win32_QuickFixEngineering" | Where-Object { $_.HotFixID -eq "" }
  10.  
  11. if ($UpdatesPending) {
  12.     Write-Host "Updates found. Starting download..."
  13.     usoclient StartDownload
  14.     Write-Host "Downloading updates. Starting installation..."
  15.     usoclient StartInstall
  16. } else {
  17.     Write-Host "No updates found."
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement