none
Why doesn't the File Version match up correctly when I use Get-ItemProperty? RRS feed

  • Question

  • Why doesn't the File Version match up correctly when I use Get-ItemProperty?

    So, why doesn't the powershell command get-itemproperty return the same File Version as the the GUI when you Right-Click and Check the details tab? This command usually returns the information I'm looking for before and after patching servers and applications.

    Important to note: The powershell command returned the same FileVersion before and after patching even after the server was rebooted.

    Gui Returns this File Version: 6.1.7601.17977

    Powershell Returns this File Version:  6.1.7600.16385 (win7_rtm.090713-1255)

    Image: http://www.screencast.com/t/pwfZSWgc9V

    This is the PowerShell Command and Results: 

    PS pshell:\>  Get-ItemProperty "\\joseph1\c$\windows\system32\win32k.sys"  | fl *


    PSPath            : Microsoft.PowerShell.Core\FileSystem::\\joseph1\c$\windows\system32\win32k.sys
    PSParentPath      : Microsoft.PowerShell.Core\FileSystem::\\joseph1\c$\windows\system32
    PSChildName       : win32k.sys
    PSProvider        : Microsoft.PowerShell.Core\FileSystem
    VersionInfo       : File:             "\\joseph1\c$\windows\system32\win32k.sys"
                        InternalName:     win32k.sys
                        OriginalFilename: win32k.sys.mui
                        FileVersion:      6.1.7600.16385 (win7_rtm.090713-1255)
                        FileDescription:  Multi-User Win32 Driver
                        Product:          Microsoftr Windowsr Operating System
                        ProductVersion:   6.1.7600.16385

    Date of Occurrence: 11/29/2012

    Thursday, November 29, 2012 4:24 PM

Answers

  • Hi,

    The basic answer is that the FileVersionInfo class (returned by the [System.Diagnostics.FileVersionInfo]::GetVersionInfo method, which is the same thing that the PowerShell VersionInfo ScriptProperty is returning) doesn't necessarily contain the same information as the actual executable version information.

    You can see the differences this way:


    PS C:\> $vi = (get-item C:\Windows\system32\win32k.sys).VersionInfo
    PS C:\> $vi.FileVersion
    6.1.7600.16385 (win7_rtm.090713-1255)
    PS C:\> "{0}.{1}.{2}.{3}" -f $vi.FileMajorPart, $vi.FileMinorPart, $vi.FileBuildPart, $vi.FilePrivatePart
    6.1.7601.17977
    

    You can see that the FileVersion property is actually a string, but the actual executable file version information is built from the four components (FileMajorPart, etc.), which are numbers.

    Bill

    • Marked as answer by InsideAzure Thursday, November 29, 2012 5:00 PM
    Thursday, November 29, 2012 4:33 PM
    Moderator

All replies

  • Hi,

    The basic answer is that the FileVersionInfo class (returned by the [System.Diagnostics.FileVersionInfo]::GetVersionInfo method, which is the same thing that the PowerShell VersionInfo ScriptProperty is returning) doesn't necessarily contain the same information as the actual executable version information.

    You can see the differences this way:


    PS C:\> $vi = (get-item C:\Windows\system32\win32k.sys).VersionInfo
    PS C:\> $vi.FileVersion
    6.1.7600.16385 (win7_rtm.090713-1255)
    PS C:\> "{0}.{1}.{2}.{3}" -f $vi.FileMajorPart, $vi.FileMinorPart, $vi.FileBuildPart, $vi.FilePrivatePart
    6.1.7601.17977
    

    You can see that the FileVersion property is actually a string, but the actual executable file version information is built from the four components (FileMajorPart, etc.), which are numbers.

    Bill

    • Marked as answer by InsideAzure Thursday, November 29, 2012 5:00 PM
    Thursday, November 29, 2012 4:33 PM
    Moderator
  • Super!

    Thanks for the quick response. You've answered this question.

    :)

    Thursday, November 29, 2012 5:00 PM