Sunday, 20 November 2011

Show-FileInformation.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script displays information returned from the  
  4.     file version object. 
  5. .DESCRIPTION 
  6.     This script gets, then displays, all the information returned 
  7.     from the System.Diagnostics.Fileinfo of Notepad.exe 
  8. .NOTES 
  9.     File Name  : Show-FileInformation.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell Version 2.0 
  12. .LINK 
  13.     This script posted to: 
  14.         http://http://pshscripts.blogspot.com 
  15.     MSDN sample posted to: 
  16.          http://msdn.microsoft.com/en-us/library/system.diagnostics.fileversioninfo_properties.aspx 
  17. .EXAMPLE 
  18.     Psh> .\Show-FileInformation.ps1 
  19.     File Major Part for C:\Windows\system32\Notepad.exe is: 6             
  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. # Display all the file information: 
  28. "FileInfo information for {0}" -f $file 
  29. "Comments           : {0}"  -f $myFileVersionInfo.Comments 
  30. "Company Name       : {0}"  -f $myFileVersionInfo.CompanyName 
  31. "FileBuldPart       : {0}"  -f $myFileVersionInfo.FileBuildPart 
  32. "FileDescription    : {0}"  -f $myFileVersionInfo.FileDescription 
  33. "FileMajorPart      : {0}"  -f $myFileVersionInfo.FileMajorPart 
  34. "FileMinorPart      : {0}"  -f $myFileVersionInfo.FileMinorPart 
  35. "FilePrivatePart    : {0}"  -f $myFileVersionInfo.FilePrivatePart 
  36. "FileName           : {0}"  -f $myFileVersionInfo.FileName  
  37. "FileVersion        : {0}"  -f $myFileVersionInfo.FileVersion 
  38. "InternalName       : {0}"  -f $myFileVersionInfo.InternalName 
  39. "IsDebug            : {0}"  -f $myFileVersionInfo.IsDebug 
  40. "IsPatched          : {0}"  -f $myFileVersionInfo.IsPatched 
  41. "IsPreRelease       : {0}"  -f $myFileVersionInfo.IsPreRelease 
  42. "IsPrivateBuild     : {0}"  -f $myFileVersionInfo.IsPrivateBuild 
  43. "IsSpecialBuild     : {0}"  -f $myFileVersionInfo.IsSpecialBuild 
  44. "Language           : {0}"  -f $myFileVersionInfo.Language 
  45. "LegalCopyright     : {0}"  -f $myFileVersionInfo.LegalCopyright 
  46. "LegalTrademarks    : {0}"  -f $myFileVersionInfo.LegalTrademarks 
  47. "OriginalFilename   : {0}"  -f $myFileVersionInfo.OriginalFilename 
  48. "PrivateBuild       : {0}"  -f $myFileVersionInfo.PrivateBuild 
  49. "ProductBuildPart   : {0}"  -f $myFileVersionInfo.ProductBuildPart 
  50. "ProductMajordPart  : {0}"  -f $myFileVersionInfo.ProductMajorPart 
  51. "ProductMinorPart   : {0}"  -f $myFileVersionInfo.ProductMinorPart 
  52. "ProductName        : {0}"  -f $myFileVersionInfo.ProductName 
  53. "ProductPrivatePart : {0}"  -f $myFileVersionInfo.ProductMinorPart 
  54. "ProductVersion     : {0}"  -f $myFileVersionInfo.ProductVersion 
  55. "SpecialBuild       : {0}"  -f $myFileVersionInfo.SpecialBuild 

No comments: