Category Archives: fileversion

Get File Version using Powershell

 

Trying to get the file version of an .EXE file using Powershell, I found the following interesting commands.

This will get the file version of an individual file:

(Get-Command %FILEPATH%).FileVersionInfo

Where %FILEPATH% is the path to a file

eg:

(Get-Command “C:Program FilesInternet ExplorerIExplore.exe”).FileVersionInfo

This will get a list of files in a directory.  (You can also add –recurse to the Get-ChildItem cmdlet to search subdirectories as well)

Get-ChildItem %FILEEXT% | ForEach-Object{Get-Command $_.FullName} | Select –Expand File*

Where %FILEEXT% is the file extension you wish to list.

eg:

Get-ChildItem “C:Program FilesInternet Explorer*.exe” | ForEach-Object(Get-Command $_.FullName} | Select –Expand File*

Using the first method, if you pipe the results to Get-Member instead of looking at the FileVersionInfo property, you can see there are also a number of other properties available:

CommandType; Definition; Extension; Module; ModuleName; Name; OutputType; Parameters; ParameterSets; Path; RemotingCapability; Visibility; FileVersionInfo; HelpUri

Reference:

http://stackoverflow.com/questions/30686/get-file-version-in-powershell