Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - get file version information

Reply
 
Old 12-06-2007   #1 (permalink)
Ryan


 
 

get file version information

So I want to find the version of a file in Powershell. How can I do this? I
don't see a fileversion property on the system.io.fileinfo object returned
from get-childitem.

My System SpecsSystem Spec
Old 12-06-2007   #2 (permalink)
Marco Shaw [MVP]


 
 

Re: get file version information

Ryan wrote:
Quote:

> So I want to find the version of a file in Powershell. How can I do this? I
> don't see a fileversion property on the system.io.fileinfo object returned
> from get-childitem.
Not everything shows up by default, try:
get-childitem some_file|get-member

Then try:
(get-childitem some_file).VersionInfo

Or:
get-childitem some_file|foreach-object{$_.VersionInfo}

Marco

--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec
Old 12-06-2007   #3 (permalink)
Kiron


 
 

Re: get file version information

Try this:

ls $env:windir explorer.exe | % {$_.VersionInfo.FileVersion}

#...or
([System.Diagnostics.FileVersionInfo]::GetVersionInfo("$env:winDir\explorer.exe")).FileVersion

--
Kiron
My System SpecsSystem Spec
Old 12-06-2007   #4 (permalink)
Kiron


 
 

Re: get file version information

Didn't mean to intrude. Marco already answered, my post was too late, just ignore it. Thanks

--
Kiron
My System SpecsSystem Spec
Old 12-06-2007   #5 (permalink)
Marco Shaw [MVP]


 
 

Re: get file version information

Kiron wrote:
Quote:

> Didn't mean to intrude. Marco already answered, my post was too late, just ignore it. Thanks
>
Actually, the user asked for the file version, and I didn't specifically
answer that...

So your answer is better! ;-)

Marco
My System SpecsSystem Spec
Old 12-06-2007   #6 (permalink)
Ryan


 
 

Re: get file version information

Hi Marco,

As an example, if I want to see the version on ntfs.sys I try:

(get-item 'c:\windows\system32\drivers\ntfs.sys').VersionInfo

It returns nothing for me. I tried what Kiron wrote too and no luck.

Ryan

"Marco Shaw [MVP]" wrote:
Quote:

> Ryan wrote:
Quote:

> > So I want to find the version of a file in Powershell. How can I do this? I
> > don't see a fileversion property on the system.io.fileinfo object returned
> > from get-childitem.
>
> Not everything shows up by default, try:
> get-childitem some_file|get-member
>
> Then try:
> (get-childitem some_file).VersionInfo
>
> Or:
> get-childitem some_file|foreach-object{$_.VersionInfo}
>
> Marco
>
> --
> Microsoft MVP - Windows PowerShell
> http://www.microsoft.com/mvp
>
> PowerGadgets MVP
> http://www.powergadgets.com/mvp
>
> Blog:
> http://marcoshaw.blogspot.com
>
My System SpecsSystem Spec
Old 12-06-2007   #7 (permalink)
Kirk Munro


 
 

Re: get file version information

Hi Ryan,

Did you try the second part of what Kiron wrote? i.e.

[System.Diagnostics.FileVersionInfo]::GetVersionInfo('C:\Windows\System32\drivers\ntfs.sys').FileVersion

This is necessary because the version information is not included as a
member of the file objects in PowerShell.

If you're doing this for a lot of files, you could add it as a member for
all of them by doing this:

Get-ChildItem C:\Windows\System32\Drivers | Add-Member -Name
FileVersion -MemberType ScriptProperty -Value
{[System.Diagnostics.FileVersionInfo]::GetVersionInfo($this.FullName).FileVersion}
-PassThru | Format-Table -Property Name,FileVersion

--
Kirk Munro
Poshoholic
http://poshoholic.com


"Ryan" <Ryan@xxxxxx> wrote in message
news:A15F5E98-5E76-4FAE-83FB-764C8FAEE5B8@xxxxxx
Quote:

> Hi Marco,
>
> As an example, if I want to see the version on ntfs.sys I try:
>
> (get-item 'c:\windows\system32\drivers\ntfs.sys').VersionInfo
>
> It returns nothing for me. I tried what Kiron wrote too and no luck.
>
> Ryan
>
> "Marco Shaw [MVP]" wrote:
>
Quote:

>> Ryan wrote:
Quote:

>> > So I want to find the version of a file in Powershell. How can I do
>> > this? I
>> > don't see a fileversion property on the system.io.fileinfo object
>> > returned
>> > from get-childitem.
>>
>> Not everything shows up by default, try:
>> get-childitem some_file|get-member
>>
>> Then try:
>> (get-childitem some_file).VersionInfo
>>
>> Or:
>> get-childitem some_file|foreach-object{$_.VersionInfo}
>>
>> Marco
>>
>> --
>> Microsoft MVP - Windows PowerShell
>> http://www.microsoft.com/mvp
>>
>> PowerGadgets MVP
>> http://www.powergadgets.com/mvp
>>
>> Blog:
>> http://marcoshaw.blogspot.com
>>

My System SpecsSystem Spec
Old 12-06-2007   #8 (permalink)
Marco Shaw [MVP]


 
 

Re: get file version information

Ryan wrote:
Quote:

> Hi Marco,
>
> As an example, if I want to see the version on ntfs.sys I try:
>
> (get-item 'c:\windows\system32\drivers\ntfs.sys').VersionInfo
>
> It returns nothing for me. I tried what Kiron wrote too and no luck.
>
> Ryan
Sorry! This is a new feature with the 2.0 CTP...

Marco


--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec
Old 12-07-2007   #9 (permalink)
Keith Hill [MVP]


 
 

Re: get file version information

"Ryan" <Ryan@xxxxxx> wrote in message
news:C3614ADE-85D2-4999-A4FB-272B72389C90@xxxxxx
Quote:

> So I want to find the version of a file in Powershell. How can I do this?
> I
> don't see a fileversion property on the system.io.fileinfo object returned
> from get-childitem.
(Get-Command <path_to_executable_binary>).FileVersionInfo.FileVersion

e.g.

PS> (gcm powershell).FileVersionInfo.FileVersion
6.0.6000.16386 (winmain(wmbla).070112-1312)

Or if you have PSCX installed:

PS> Get-FileVersionInfo C:\Windows\system32\user32.dll

ProductVersion FileVersion FileName
-------------- ----------- --------
6.0.6000.16386 6.0.6000.1638... C:\Windows\system32\user32.dll

--
Keith
http://www.codeplex.com/powershellcx

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Retrieve file version information PowerShell
File version information? Vista General
Version information in Explorer's File Details Tab Vista file management
File version information limited in Windows Explorer on Vista Vista General
Where to save trial version information? Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46