locked
Checking installed Patches remotely - How direct this script to other servers? RRS feed

  • Question

  • Hello,

    I have a script I received from other admins a while back, used to pull patch installs from the Microsoft Update Session. This script is preferred because of the details provides about the patches.

    Does anyone know how I can direct this script to other server(s) on my network? This would be the most important part as it would save time from logging into each server manually.

    Lastly, can a range of dates be proved for patches installed? Important, but not near as important as trying to get the script to check remote servers.

    From what little I know of PowerShell , I've tried to use a list for it to access for other serves as I've done with other scripts, but couldn't figure out how to do it with this script.

    The original script is below.

    ======================================

    $Session = New-Object -ComObject "Microsoft.Update.Session"
    
    $Searcher = $Session.CreateUpdateSearcher()
    
    $historyCount = $Searcher.GetTotalHistoryCount()
    
    $Searcher.QueryHistory(0, $historyCount) | Select-Object Date,
    
       @{name="Operation"; expression={switch($_.operation){
    
           1 {"Installation"}; 2 {"Uninstallation"}; 3 {"Other"}}}},
    
       @{name="Status"; expression={switch($_.resultcode){
    
           1 {"In Progress"}; 2 {"Succeeded"}; 3 {"Succeeded With Errors"};
    
           4 {"Failed"}; 5 {"Aborted"}
    
    }}}, Title |  Out-GridView

    Friday, November 17, 2017 6:09 PM

Answers

  • Here is a simple example:

    $session = [activator]::CreateInstance([type]::GetTypeFromProgID('Microsoft.Update.Session',$pc))
    $searcher = $session.CreateUpdateSearcher()
    $totalupdates = $searcher.GetTotalHistoryCount()
    $searcher.QueryHistory(0, $totalupdates)


    \_(ツ)_/


    • Edited by jrv Friday, November 17, 2017 6:58 PM
    • Proposed as answer by BOfH-666 Friday, November 17, 2017 11:39 PM
    • Marked as answer by LosingSleep Friday, January 12, 2018 12:05 AM
    Friday, November 17, 2017 6:56 PM

All replies

  • Look in Gallery for scripts that can do this remotely.


    \_(ツ)_/

    Friday, November 17, 2017 6:48 PM
  • Here is a simple example:

    $session = [activator]::CreateInstance([type]::GetTypeFromProgID('Microsoft.Update.Session',$pc))
    $searcher = $session.CreateUpdateSearcher()
    $totalupdates = $searcher.GetTotalHistoryCount()
    $searcher.QueryHistory(0, $totalupdates)


    \_(ツ)_/


    • Edited by jrv Friday, November 17, 2017 6:58 PM
    • Proposed as answer by BOfH-666 Friday, November 17, 2017 11:39 PM
    • Marked as answer by LosingSleep Friday, January 12, 2018 12:05 AM
    Friday, November 17, 2017 6:56 PM
  • Thanks for the snipped above.

    Where is the Gallery?

    Thx.

    Friday, November 17, 2017 7:37 PM
  • Gallery

    \_(ツ)_/

    Friday, November 17, 2017 7:41 PM