locked
Get Hot fix to give result only latest updates RRS feed

  • Question

  • Im trying to get patches installed on remote computers written a script using Get-Hotfix –cn $Computer | Select HotfixID, Description, InstalledOn | sort InstalledOn

    It is giving me all the updates installed on the computer. I want only the latest list. 

    I saw syntax for where object with Date, but i dont want to write my script with specific/range of date. I want only the last installed updates to show.. Can anyone help me how do i achieve this using above get hot fix commandlet

    Tuesday, July 25, 2017 8:16 AM

Answers

  • What are the last installed updates?

    To see updates in the correct order:

    Get-Hotfix –cn $Computer | sort installedon -Descending


    \_(ツ)_/

    • Marked as answer by D A S Thursday, July 27, 2017 5:04 PM
    Tuesday, July 25, 2017 8:55 AM
  • One solution could be this:
    Get-HotFix -ComputerName $Computer -OutVariable AllFixes | 
        Sort-Object -Property InstalledOn | 
            Select-Object -Last 1 -OutVariable LatestFix
    $AllFixes | 
        Where-Object {$_.InstalledOn -eq $LatestFix.InstalledOn}


    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''


    • Edited by BOfH-666 Tuesday, July 25, 2017 9:01 AM
    • Marked as answer by D A S Thursday, July 27, 2017 4:59 PM
    • Unmarked as answer by D A S Thursday, July 27, 2017 4:59 PM
    • Marked as answer by D A S Thursday, July 27, 2017 5:04 PM
    Tuesday, July 25, 2017 9:00 AM

All replies

  • What are the last installed updates?

    To see updates in the correct order:

    Get-Hotfix –cn $Computer | sort installedon -Descending


    \_(ツ)_/

    • Marked as answer by D A S Thursday, July 27, 2017 5:04 PM
    Tuesday, July 25, 2017 8:55 AM
  • One solution could be this:
    Get-HotFix -ComputerName $Computer -OutVariable AllFixes | 
        Sort-Object -Property InstalledOn | 
            Select-Object -Last 1 -OutVariable LatestFix
    $AllFixes | 
        Where-Object {$_.InstalledOn -eq $LatestFix.InstalledOn}


    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''


    • Edited by BOfH-666 Tuesday, July 25, 2017 9:01 AM
    • Marked as answer by D A S Thursday, July 27, 2017 4:59 PM
    • Unmarked as answer by D A S Thursday, July 27, 2017 4:59 PM
    • Marked as answer by D A S Thursday, July 27, 2017 5:04 PM
    Tuesday, July 25, 2017 9:00 AM
  • Thanks everyone. Your suggestion helped a lot. I could achieve the desired results.

    I'm getting resultant columns (Source,Description, HotFixID Installed by, InstalledOn) with data. So how can i export same column data to excel. I tried using Export CSV command-let but that gives me someother unnecessary coulmns. I tried to format table but didnt help. Can you please suggest how do i get the same data with same columns in file

    Thursday, July 27, 2017 5:04 PM
  • Also , can we get the count of the updates in other column using this. I mean the latest updates installed count
    Get-HotFix -ComputerName $Computer -OutVariable AllFixes | 
        Sort-Object -Property InstalledOn | 
            Select-Object -Last 1 -OutVariable LatestFix
    $AllFixes | 
        Where-Object {$_.InstalledOn -eq $LatestFix.InstalledOn}
    Thursday, July 27, 2017 5:14 PM
  • You can select with the cmdlet Select-Object which properties you want to output, then you export this with Export-CSV. Read the help for these cmdlets including the examples, play a little with it and you will know how to use.

    The amount of updates you can have with $AllFixes.Count.


    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''


    • Edited by BOfH-666 Thursday, July 27, 2017 8:11 PM
    Thursday, July 27, 2017 8:10 PM