Sunday, 13 November 2011

Show-FileBuildPart.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script shows the build number of file version object. 
  4. .DESCRIPTION 
  5.     This script is a re-implementation of an MSDN Sample script 
  6.     that uses System.Diagnostics.FileVersionInfo to get 
  7.     the build identification of the file. 
  8. .NOTES 
  9.     File Name  : Show-FileBuildPart.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell Version 2.0 
  12. .LINK 
  13.     This script posted to: 
  14.         http://pshscripts.blogspot.com/2011/11/show-filebuildpartps1.html 
  15.     MSDN sample posted to: 
  16.          http://msdn.microsoft.com/en-us/library/system.diagnostics.fileversioninfo.filebuildpart.aspx   
  17. .EXAMPLE 
  18.     Psh> .\Show-FileBuildPart.ps1 
  19.     File build number for C:\Windows\system32\Notepad.exe is: 6001 
  20. #> 
  21. # Set filename 
  22. $File = [System.Environment]::SystemDirectory + "\Notepad.exe" 
  23.  
  24. #Get Version information for this file 
  25. $myFileVersionInfo = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($File
  26.  
  27. # Print the Build details name 
  28. "File build number for {0} is: {1}"  -f $file,$myFileVersionInfo.FileBuildPart 

1 comment:

mdshell said...

Thanks for posting this. I appreciate you for this.



Sample Documents