Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need help converting "InstalledOn" date for all Win32_QuickFixEngineering entries

796 views
Skip to first unread message

MikeBlane

unread,
Mar 19, 2010, 4:57:59 PM3/19/10
to

Hello, all. I'm new to Powershell scripting, but have used VBScript for
years. I've found that there is no way in VBScript to do the following
and am hoping someone can help with a PowerShell script for the
following:

I need to be able to document all of the HotFixIDs, their
description, and the date that the HotFixes were installed. I want this
list to be a CSV list available in the root directory of the computers
that need this information. All of the computers that I'm going to use
this on are 64-bit computers and are running Windows Server 2008 and
Vista.
I found a powershell script on 'www.minasi.com'
(http://www.minasi.com) that works for a single KB entry, but I need a
list for the entire set of hotfixes. I've included the script from
'www.minasi.com' (http://www.minasi.com) here so that you can see what I
am looking at. The full link to the minasi forum is 'Mark Minasi's
Reader Forum - Find HotFix'
(http://www.minasi.com/forum/topic.asp?TOPIC_ID=29446).
---------------
$a = gwmi Win32_QuickFixEngineering | where {$_.HotFixID -match
"KB925902"}
$a
$objSID = New-Object System.Security.Principal.SecurityIdentifier `
($a.InstalledBy)
$objUser = $objSID.Translate( [System.Security.Principal.NTAccount])

Write-host "Translated SID"
$objUser.Value
Write-Host "Translated InstalledOn, on Vista 64 bit it is in the 64 Bit
UTC date format"


[datetime]::FromFileTimeUTC([Convert]::ToInt64($a.InstalledOn,16))
------------
I'd like the final output to be something like this:

KB948465,Service Pack, 3/19/2010


Thanks in advance for your help with this.


--
MikeBlane

PaulChavez

unread,
Mar 19, 2010, 11:31:01 PM3/19/10
to

"MikeBlane" wrote:

>
> Hello, all. I'm new to Powershell scripting, but have used VBScript for
> years. I've found that there is no way in VBScript to do the following
> and am hoping someone can help with a PowerShell script for the
> following:
>
> I need to be able to document all of the HotFixIDs, their
> description, and the date that the HotFixes were installed. I want this
> list to be a CSV list available in the root directory of the computers
> that need this information. All of the computers that I'm going to use
> this on are 64-bit computers and are running Windows Server 2008 and
> Vista.
>

> I'd like the final output to be something like this:
>
> KB948465,Service Pack, 3/19/2010
>
>
> Thanks in advance for your help with this.
>
>
> --
> MikeBlane

> .
>

get-wmiobject win32_quickfixengineering |
where-object {$_.Description} |
select-object HotFixID, Description, InstalledOn |
Export-CSV c:\HotfixInfo.csv


MikeBlane

unread,
Mar 20, 2010, 1:01:30 AM3/20/10
to


Paul, Wow! Thank you! That does everything that I need except the date
conversion to an understandable format. When I ran that on my Vista
computer, the output looks like:

KB977165,"Security Update",01caa9fce57cf3d7

Which puts the information in the correct format - Thank you! - but the
date ends up in the Long Integer 64bit format. I've seen examples that
the "[datetime]::FromFileTimeUTC([Convert]::ToInt64($_.InstalledOn,16))"
line will correctly convert the date to a readable format. I'm not sure
if there is a mm/dd/yyyy format available in the string. Any ideas how
to implement that part?


--
MikeBlane

Chris Dent

unread,
Mar 20, 2010, 7:15:50 AM3/20/10
to

You just need a custom property in the Select-Object statement:

Get-WMIObject Win32_QuickFixEngineering |
Where-Object { $_.Description } |
Select-Object HotFixID, Description, `
@{n='InstalledOn';e={
[DateTime]::FromFileTimeUTC([Convert]::ToInt64($_.InstalledOn,
16)).ToString("MM/dd/yy") }}

I added ToString and a date time format string on the end which should
deal with producing the format you want.

Chris

PaulChavez

unread,
Mar 20, 2010, 12:30:05 PM3/20/10
to
Ah, I was using V2 and the date is already converted using that cmdlet,
apparently. Chris posted the right answer.

"MikeBlane" wrote:

> .
>

0 new messages