Thursday, 14 July 2011

Show-MinorPart.ps1

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