Advertisement
ibi

check_missing_updates.ps1

ibi
Nov 14th, 2016
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # what: lists missing windows updates, compares to offline repo
  2. # when: manual/scheduled, especially after patch tuesdays
  3. # who: ibi c/o doctordeploy.com
  4. # whose: CC BY-SA 4.0 - provided as-is, use at your own risk. tested only with win 8.1
  5. # based on https://msdn.microsoft.com/en-us/library/windows/desktop/aa387290(v=vs.85).aspx
  6.  
  7. # where: needs wsusscn2.cab in c:\temp as you've already figured out
  8. # - located at [wsusofflinedir]\client\wsus
  9. # - downloadable at http://go.microsoft.com/fwlink/?LinkId=76054
  10.  
  11. $UpdateSession = New-Object -ComObject "Microsoft.Update.Session"
  12. $UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
  13. $UpdateServiceManager = New-Object -ComObject "Microsoft.Update.ServiceManager"
  14. $UpdateService = $UpdateServiceManager.AddScanPackageService("Offline Sync Service", "c:\temp\wsusscn2.cab")
  15.  
  16. write "Searching for Updates. Please wait..."
  17. $UpdateSearcher.ServerSelection = 3
  18. $UpdateSearcher.ServiceID = $UpdateService.ServiceID
  19. $SearchResult = $UpdateSearcher.Search("IsInstalled=0")
  20. $Updates = $SearchResult.Updates
  21.  
  22. write "List of applicable items on the machine when using wsusscn2.cab:"
  23. $Updates | select title, type, ismandatory, maxdownloadsize, lastdeploymentchangetime | fl
  24.  
  25. # use e.g. "$Updates | tee \\server1\logs\mua_$env:computername.log" to redirect output to file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement