filepowershellversioninfo

Get file version in PowerShell


How can you get the version information from a .dll or .exe file in PowerShell?

I am specifically interested in File Version, though other version information (that is, Company, Language, Product Name, etc.) would be helpful as well.


Solution

  • Since PowerShell can call .NET classes, you could do the following:

    [System.Diagnostics.FileVersionInfo]::GetVersionInfo("somefilepath").FileVersion
    

    Or as noted here on a list of files:

    get-childitem * -include *.dll,*.exe | foreach-object { "{0}`t{1}" -f $_.Name, [System.Diagnostics.FileVersionInfo]::GetVersionInfo($_).FileVersion }
    

    Or even nicer as a script: https://jtruher3.wordpress.com/2006/05/14/powershell-and-file-version-information/