Saturday 23 May 2009

Get-FileVersionInfo.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script gets and displays the file version information of a file 
  4. .DESCRIPTION 
  5.     This script calls System.Diagnostics.FileVersionInfo's  
  6.     GetVersion info method on the file. By default, the file version 
  7.     displayed/returned is that of %systemroot%\notepad.exe.  
  8. .NOTES 
  9.     File Name  : Get-FileVersionInfo.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell V2 CTP3 
  12.     Note       : The file named passed to GetVersionInfo needs to  
  13.                  be fully qualified, not just local name. 
  14. .LINK 
  15.     This script posted to: 
  16.       http://www.pshscripts.blogspot.com 
  17.     MSDN Sample posted at: 
  18.       http://msdn.microsoft.com/en-us/library/system.diagnostics.fileversioninfo.aspx 
  19. .EXAMPLE 
  20.     PSH [C:\foo]: .\Get-FileVersionInfo.ps1 
  21.     File Description : Notepad 
  22.     File Version     : 6.0.6000.16386 (vista_rtm.061101-2205) 
  23. .EXAMPLE 
  24.     PSH [C:\Foo]: .\Get-FileVersionInfo.ps1' c:\windows\fveupdate.exe 
  25.     File Description : BitLocker Drive Encryption Servicing Utility 
  26.     File Version     : 6.0.6000.16386 (vista_rtm.061101-2205) 
  27. .PARAMETER filename 
  28.     The name of the file for which file version information is displayed. 
  29. #> 
  30.  
  31. param
  32. [string] $filename = $(join-path ${env:systemroot} "Notepad.Exe"
  33.  
  34. ## 
  35. # start of script 
  36. ## 
  37.  
  38. $info= [system.Diagnostics.FileVersionInfo]::GetVersionInfo($filename
  39. "File Description : {0}" -f  $info.filedescription 
  40. "File Version     : {0}" -f  $info.fileversion 
  41.   

2 comments:

SujithVasudevan said...

Thank you Very much !!!

Very usefull.

Regards,
Sujith

SujithVasudevan said...

Than you very much !!!
It is useful