locked
Getting file Assembly Version RRS feed

  • Question

  • Hi,

    I'm trying to get hold of the Assembly Version property of dll files.

    I have $a = get-item c:\temp\myfile.dll.
    $a.VersionInfo gives me a whole range of information, but no the Assembly Version number I see when I right click the dll and go to Properties, then the Versions tab.

    Is there a way I can get at this number through Powershell?


    Thanks
    M
    Tuesday, May 12, 2009 3:00 PM

Answers

  • Hi,

    Maybe you can use the Reflection.Assembly class :

    $strPath = 'c:\my_PE_file.dll'
    $Assembly = [Reflection.Assembly]::Loadfile($strPath) $AssemblyName = $Assembly.GetName() $Assemblyversion = $AssemblyName.version
    Hope it helps.
    Grégory Schiro - PowerShell & MOF
    • Proposed as answer by Grégory Schiro Wednesday, May 13, 2009 7:56 AM
    • Marked as answer by Lindemann Wednesday, May 13, 2009 8:02 AM
    Wednesday, May 13, 2009 7:56 AM

All replies

  • Hi,

     

    Do you want to get all the value in Version Property of a file? Such as Company, File Version Internal name etc.

     

    You can use the following command:

    ----------------------------------------

    gcm C:\WINDOWS\system32\authz.dll | fl

    ----------------------------------------

    Note: Please replace "C:\WINDOWS\system32\authz.dll" as the file path of the file your want to get. For the system file like notepad.exe, regedit.exe, you can just type notepad or regedit instead.

     

    After you perform the above command, you will get the following information:

    08

     


    In addition, if you want to run this for a bunch of files, you can perform the following steps:

     

    1. Please navigate to the folder you want, such as c:\windows.

    2. Please run the command:

    ---------------------------------------------

    gci *.exe | resolve-path | gcm | %{$_.FileVersionInfo} |fl

    ---------------------------------------------

     

    You can specify the value you want like the following command:

    ---------------------------------------------

    gci *.exe | resolve-path | gcm | %{$_.FileVersionInfo} |fl ProductName, ProductVersion

    ---------------------------------------------

     

     

    Best regards,

    Vincent Hu

    • Edited by Vincent Hu Wednesday, May 13, 2009 6:43 AM
    Wednesday, May 13, 2009 4:27 AM
  • Hi Vincent,

    Thanks for your reply. However, I can get hold of the product version and file version ok enough. I'm specifically working with .net compiled dlls, and they have an assembly version property as well, and it's this that I'm really after.


    Wednesday, May 13, 2009 7:45 AM
  • Hi,

    Maybe you can use the Reflection.Assembly class :

    $strPath = 'c:\my_PE_file.dll'
    $Assembly = [Reflection.Assembly]::Loadfile($strPath) $AssemblyName = $Assembly.GetName() $Assemblyversion = $AssemblyName.version
    Hope it helps.
    Grégory Schiro - PowerShell & MOF
    • Proposed as answer by Grégory Schiro Wednesday, May 13, 2009 7:56 AM
    • Marked as answer by Lindemann Wednesday, May 13, 2009 8:02 AM
    Wednesday, May 13, 2009 7:56 AM
  • Hi Grégory,

    That's done the trick. Thank you very much!
    Wednesday, May 13, 2009 8:02 AM