Sunday, 13 November 2011

ShowFileDescription.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script shows the build description 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 description of the file. 
  8. .NOTES 
  9.     File Name  : Show-FileDescription.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/showfiledescriptionps1.html 
  15.     MSDN sample posted to: 
  16.          http://msdn.microsoft.com/en-us/library/system.diagnostics.fileversioninfo.filedescription.aspx  
  17. .EXAMPLE 
  18.     Psh> .\Show-FileDescription.ps1 
  19.     File description for C:\Windows\system32\Notepad.exe is: Notepad 
  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 description for {0} is: {1}"  -f $file,$myFileVersionInfo.FileDescription 

No comments: