Converting the FileSystemObject's GetFileVersion Method

Windows PowerShell

Definition: Returns the version of a given file.


The .NET Framework static object FileVersionInfo can be used to retrieve this information. Simply call the GetVersionInfo method, passing it the name of the file. This method will return several properties related to the file version, so in this example we’ve piped the output to the Select-Object cmdlet to retrieve only the FileVersion property.

[System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\Windows\cttib1.dll") | Select-Object FileVersion

See conversions of other FileSystemObject methods and properties.
Return to the VBScript to Windows PowerShell home page