Get-HotFix and get-WmiObject Win32_QuickFixEngineering missing InstalledOn property

Hello All

When using either of the above,  most of my HotFixes show no InstalledOn or InstalledDate

However when I look in Control Panel > Programs and Features > View Installed Updates

they all show an Installed On date

I want to collect this information from local/remote computers and will therefore use the WMI option in my environment, but I need to retrieve the InstalledOn

If the above has a bug perhaps I need to go looking around in the registry,

any help most appreciated

Thanks

Ernie

Parents
No Data
Reply
  • I found that InstalledOn is a script paramter defined by the following:

    Get-HotFix | gm -Name installedon | Select-Object -ExpandProperty definition
    System.Object InstalledOn {get=if ([environment]::osversion.version.build -ge 7000)
    {
    # WMI team fixed the formatting issue related to InstalledOn
    # property in Windows7 (to return string)..so returning the WMI's
    # version directly
    [DateTime]::Parse($this.psBase.properties["InstalledOn"].Value)
    }
    else
    {
    $orig = $this.psBase.properties["InstalledOn"].Value
    $date = [datetime]::FromFileTimeUTC($("0x" + $orig))
    if ($date -lt "1/1/1980")
    {
    if ($orig -match "([0-9]{4})([01][0-9])([012][0-9])")
    {
    new-object datetime @([int]$matches[1], [int]$matches[2], [int]$matches[3])
    }
    }
    else
    {
    $date
    }
    };}

    In my case, my locale is set as en-GB (UK locale) however, upon checking the values for InstalledOn the dates were formatted in mm/dd/yyyy, causing an error in parsing the string value to a datetime property with the parse method (as seen above which the scriptproperty is based on), hence the InstalledOn property appears empty. Here's what I did to work around this:

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

    FYI I did this all on one line but sometimes on this forum if the line is too long it will go off screen so I separated it onto multiple lines.

Children