code_junkie

get file version in powershell

Nov 10th, 2011
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. [System.Diagnostics.FileVersionInfo]::GetVersionInfo("somefilepath").FileVersion
  2.  
  3. get-childitem * -include *.dll,*.exe | foreach-object { "{0}`t{1}" -f $_.Name, [System.Diagnostics.FileVersionInfo]::GetVersionInfo($_).LegalCopyright }
  4.  
  5. (Get-Command C:PathYourFile.Dll).FileVersionInfo
  6.  
  7. dir *.dll,*.exe | %{gcm $_.FullName} | select -expand File*
  8.  
  9. PS C:Windows> (dir .write.exe).VersionInfo | fl
  10.  
  11.  
  12. OriginalFilename : write
  13. FileDescription : Windows Write
  14. ProductName : Microsoft® Windows® Operating System
  15. Comments :
  16. CompanyName : Microsoft Corporation
  17. FileName : C:Windowswrite.exe
  18. FileVersion : 6.1.7600.16385 (win7_rtm.090713-1255)
  19. ProductVersion : 6.1.7600.16385
  20. IsDebug : False
  21. IsPatched : False
  22. IsPreRelease : False
  23. IsPrivateBuild : False
  24. IsSpecialBuild : False
  25. Language : English (United States)
  26. LegalCopyright : © Microsoft Corporation. All rights reserved.
  27. LegalTrademarks :
  28. PrivateBuild :
  29. SpecialBuild :
  30.  
  31. PS C:Windows> dir *.exe | %{ $_.VersionInfo }
  32.  
  33. ProductVersion FileVersion FileName
  34. -------------- ----------- --------
  35. 6.1.7600.16385 6.1.7600.1638... C:Windowsbfsvc.exe
  36. 6.1.7600.16385 6.1.7600.1638... C:Windowsexplorer.exe
  37. 6.1.7600.16385 6.1.7600.1638... C:Windowsfveupdate.exe
  38. 6.1.7600.16385 6.1.7600.1638... C:WindowsHelpPane.exe
  39. 6.1.7600.16385 6.1.7600.1638... C:Windowshh.exe
  40. 6.1.7600.16385 6.1.7600.1638... C:Windowsnotepad.exe
  41. 6.1.7600.16385 6.1.7600.1638... C:Windowsregedit.exe
  42. 6.1.7600.16385 6.1.7600.1638... C:Windowssplwow64.exe
  43. 1,7,0,0 1,7,0,0 C:Windowstwunk_16.exe
  44. 1,7,1,0 1,7,1,0 C:Windowstwunk_32.exe
  45. 6.1.7600.16385 6.1.7600.1638... C:Windowswinhlp32.exe
  46. 6.1.7600.16385 6.1.7600.1638... C:Windowswrite.exe
  47.  
  48. [System.Diagnostics.FileVersionInfo]::GetVersionInfo("PathToFile.dll")
  49.  
  50. [System.Diagnostics.FileVersionInfo]::GetVersionInfo("PathToFile.dll")
  51.  
  52. [System.Diagnostics.FileVersionInfo]::GetVersionInfo("PathToFile.dll")
  53.  
  54. [System.Diagnostics.FileVersionInfo]::GetVersionInfo(path).CompanyName
Add Comment
Please, Sign In to add comment