none
Get-Hotfix cmdlet will not return dates RRS feed

  • Question

  • I tried this on Windows 7 & Windows 2003, the get-hotfix command will return blank installedon column. What I tried is get-hotfix | select hotfixid, installedon | sort-object installedon & what I get is simply list of hotfix but no date next to them. I tried this running remotely get-hotfix -computername server7 | select hotfixid, installedon | sort-object installedon & the results were same - long list of hotfix with no data in installedon column. Am I doing it wrong? Why will it not return dates? What I am trying to achieve is to get last patched dates on servers. Thanks in advance. 

    Update 1: wmic qfe list will return everything including dates but what if I only want installedon data

    Update 2: Get-WmiObject win32_quickfixengineering returns source, description, hotfixid, installedby BUT no installedon data

    Update 3: wmic /node:server7 qfe get hotfixid,installedon gives me bit of what I want but how do I sort the dates?


    • Edited by strike3test Friday, February 15, 2013 12:48 AM
    Thursday, February 14, 2013 11:07 PM

Answers

  • Thanks Ravi, this not limited to one server which now makes me think whether its some group policy restriction. You can see below that appwiz shows the updates with dates but cmdlet get-hotfix | select hotfixid, installedon | sort-object installedon doesnt work the way it is supposed to. I didnt find anything in event viewer which even remotely hints to what the problem is.

    • Marked as answer by strike3test Wednesday, March 13, 2013 12:37 AM
    Wednesday, February 20, 2013 12:29 AM

All replies

  • Hi, 

    If you want to get hotfix details along with installed date means run below command.

    Start>run>cmd(with elavated rights)>C:\wmic qfe list >hotfix.csv.

    Then explore system and got C root, search for the file hotfix.csv and open with excel sort hotfix details with KB number or Installed date etc.

    All the commands shared by you are the same but after typing the command choose the path of filename.csv then open with excel.


    Regards, Ravikumar P

    Friday, February 15, 2013 3:55 PM
  • Thanks Ravi albeit that really doesn't solve my problem. Why wont get-hotfix show dates? Why do I have to make it a 2 part process? running command to send result to an excel file & then sorting within excel. Why cant it be done in powershell console or command prompt if I am using wmic command?
    Friday, February 15, 2013 6:29 PM
  • Thanks Ravi albeit that really doesn't solve my problem. Why wont get-hotfix show dates? Why do I have to make it a 2 part process? running command to send result to an excel file & then sorting within excel. Why cant it be done in powershell console or command prompt if I am using wmic command?

    The reason behind telling to export to CSV means we can make a report in desired way by sorting desired column.

    Anyway if you want to output only with KB & installed date, just run below PS command, it gives both columns.Seems it hiding other columns of output and showing only showing hotfixID & installed date.

    get-hotfix | select hotfixid, installedon | sort-object installedon 


    Regards, Ravikumar P

    Saturday, February 16, 2013 5:12 AM
  • Yep, that's pretty much the question, I know the command & understand how it works but executing it won't give me desired results. Please see below for what I get after running get-hotfix | select hotfixid,installedon | sort-object installedon. The first one is grid out view & the second is text out. No dates at all???? Is there a expand/unhide switch that I can use (referring to your comment that its hiding the values).


    hotfixid                                InstalledOn                            
    --------                                -----------                            
    KB2641690                                                                      
    KB2644615                                                                      
    KB2645640                                                                      
    KB2640148                                                                      
    KB2631813                                                                      
    KB2633952                                                                      
    KB2637692                                                                      
    KB2656373                                                                      
    KB2656411                                                                      
    KB2658846                                                                      
    KB2656356                                                                      
                            
    KB2536275                                                                      
    KB2536276                                                                      
    KB2539635                                                                      
    KB2506143                               02/07/2013 12:00:00 AM                 


    • Edited by strike3test Sunday, February 17, 2013 10:34 PM
    Sunday, February 17, 2013 9:15 PM
  • hi all, please can I have further help on this?
    Tuesday, February 19, 2013 3:07 AM
  • I have tested this command "get-hotfix | select hotfixid, installedon | sort-object installedon " in my test machine and able to get all hot-fix info with corresponding installed dates. 

    Is this kind of issue you get only particular server or with the all servers? If so, check the event viewer of problematic server and troubleshoot based on the errors.If any?


    Regards, Ravikumar P

    Tuesday, February 19, 2013 7:57 AM
  • Thanks Ravi, this not limited to one server which now makes me think whether its some group policy restriction. You can see below that appwiz shows the updates with dates but cmdlet get-hotfix | select hotfixid, installedon | sort-object installedon doesnt work the way it is supposed to. I didnt find anything in event viewer which even remotely hints to what the problem is.

    • Marked as answer by strike3test Wednesday, March 13, 2013 12:37 AM
    Wednesday, February 20, 2013 12:29 AM
  • Try This:

    You have to create an expression that format the date as string variable as seen next:

    Note: The expression function applied to the CSname is not necessary (you can skip it by using CSname directly) it's used to get the "computer name" as a label of the CSname member rather than the CSname.

    Here is the PowerShell script:

    $ComputerName = Read-Host "Enter The Computer Name"
    $GetHotFix = Get-HotFix -ComputerName $ComputerName  |  Where-Object {$_.InstalledOn} | Sort-Object InstalledOn -Descending |  Select-Object @{Name="Computer Name"; Expression={$_.CSname}}, HotfixID, @{Name="Installation Date"; Expression={"{0:dd MMMM yyyy}" -f [datetime] $_.InstalledOn.Tostring()}}









    • Edited by Néjm-Eddine Wednesday, October 30, 2013 5:02 PM
    Wednesday, October 30, 2013 4:56 PM
  • Here's how

    Get-HotFix -ComputerName A COMPUTER | 
    where-object {$_.hotfixid -ne "file 1"} |
    Select hotfixid,description,installedby,@{label="InstalledOn";e={[DateTime]::Parse($_.psbase.properties["installedon"].value,$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}} 

    • Proposed as answer by Garethm112 Thursday, February 4, 2016 11:35 AM
    Monday, November 25, 2013 11:31 AM
  • A PowerShell script to list all installed Microsoft Windows Updates.

    Download the script from Microsoft's Technet Website.

    Function Get-MSHotfix 
    { 
        $outputs = Invoke-Expression "wmic qfe list" 
        $outputs = $outputs[1..($outputs.length)] 
         
         
        foreach ($output in $Outputs) { 
            if ($output) { 
                $output = $output -replace 'y U','y-U' 
                $output = $output -replace 'NT A','NT-A' 
                $output = $output -replace '\s+',' ' 
                $parts = $output -split ' ' 
                New-Object -Type PSObject -Property @{ 
                    KBArticle = [string]$parts[0] 
                    Computername = [string]$parts[1] 
                    Description = [string]$parts[2] 
                    FixComments = [string]$parts[6] 
                    HotFixID = [string]$parts[3] 
                    InstalledOn = [datetime]::ParseExact($parts[5], "M/d/yyyy", $null) 
                    InstalledBy = [string]$parts[4] 
                    InstallDate = [string]$parts[7] 
                    Name = [string]$parts[8] 
                    ServicePackInEffect = [string]$parts[9] 
                    Status = [string]$parts[10] 
                } 
            } 
        } 
    }
    Get-MSHotfix|Where-Object {$_.Installedon -gt ((Get-Date).Adddays(-2))}|Select-Object -Property Computername, KBArticle,InstalledOn, HotFixID, InstalledBy|Format-Table

    The above POSH oneliner lists all updates installed in the last 2 days and tabulates properties: Computername, KBArticle,InstalledOn, HotFixID and InstalledBy



    • Edited by Topaz.Paul Thursday, July 17, 2014 1:15 AM edit spaces
    Thursday, July 17, 2014 1:14 AM
  • nope, it doesent work either!

    Only few WU is in output.

    please help, I have the same problem!

    Friday, October 17, 2014 12:11 PM
  • Hi Folks,

    here is a nice workaround to fix this issue:

    Get-HotFix | Select-Object description,hotfixid,installedby,@{l="InstalledOn";e={[DateTime]::Parse($_.psbase.properties["installedon"].value,$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}}

    In my case it fixed this issues and returns stable, complete informations.

    I've found it here: http://powershell.com/cs/forums/t/12409.aspx

    Regards

    Heyko

    • Proposed as answer by heyko Thursday, January 28, 2016 8:39 AM
    Thursday, January 28, 2016 8:39 AM
  • Here's how

    Get-HotFix -ComputerName A COMPUTER | 
    where-object {$_.hotfixid -ne "file 1"} |
    Select hotfixid,description,installedby,@{label="InstalledOn";e={[DateTime]::Parse($_.psbase.properties["installedon"].value,$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}} 

    this worked great! but i can be slightly improved. 

    Get-HotFix -ComputerName localhost | where-object {$_.hotfixid -ne "file 1"} | Select hotfixid,description,installedby,@{label="InstalledOn";e={[DateTime]::Parse($_.psbase.properties["installedon"].value,$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}} | Where-Object InstalledOn -gt ([DateTime]::Parse('01/01/2016'))
    Thursday, February 4, 2016 11:36 AM
  • I know this is old but for anyone else looking to figure it out, we ran into the same issue. Anything pre 2008 R2 brings back the date in HEX. 2008 R2 and on bring back the date as get-hotfix requires it. Same with the wmic command. 
    • Proposed as answer by Nyuk_Cubed Friday, July 22, 2016 5:23 PM
    Friday, July 22, 2016 5:13 PM