Need help converting "InstalledOn" date for all Win32_QuickFixEngineering entries

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
0
MikeBlane
3/19/2010 8:57:59 PM
windows.powershell 690 articles. 0 followers. Follow

4 Replies
4830 Views

Similar Articles

[PageSpeed] 25


"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


0
Utf
3/20/2010 3:31:01 AM
PaulChavez;1243654 Wrote: 
> "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


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
0
MikeBlane
3/20/2010 5:01:30 AM
MikeBlane wrote:
> PaulChavez;1243654 Wrote: 
>> "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
> 
> 
> 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?
> 
> 

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
0
Chris
3/20/2010 11:15:50 AM
Ah, I was using V2 and the date is already converted using that cmdlet, 
apparently. Chris posted the right answer.

"MikeBlane" wrote:

> 
> PaulChavez;1243654 Wrote: 
> > "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
> 
> 
> 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
> .
> 
0
Utf
3/20/2010 4:30:05 PM
Reply:

Similar Artilces:

Need help converting "InstalledOn" date for all Win32_QuickFixEngineering entries
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 ...