在PowerShell中获取文件版本 [英] Get file version in PowerShell

查看:187
本文介绍了在PowerShell中获取文件版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从PowerShell中的 .dll .exe 文件获取版本信息?



我对文件版本特别感兴趣,虽然其他版本信息(即公司语言产品名称等)也将有所帮助。

解决方案

由于PowerShell可以调用 .NET 类,您可以执行以下操作:

  [System.Diagnostics.FileVersionInfo] :: GetVersionInfo somefilepath)。FileVersion 

或者作为在此记录在文件列表中:

  get-childitem * -include * .dll,*。exe | foreach-object {{0}`t {1}-f $ _。Name,[System.Diagnostics.FileVersionInfo] :: GetVersionInfo($ _)。FileVersion} 
/ pre>

甚至更好的脚本: http://jtruher.spaces.live.com/blog/cns!7143DA6E51A2628D!125.entry


How can you get the version information from a .dll or .exe file in PowerShell?

I am specifically interested in File Version, though other version information (that is, Company, Language, Product Name, etc.) would be helpful as well.

解决方案

Since PowerShell can call .NET classes, you could do the following:

[System.Diagnostics.FileVersionInfo]::GetVersionInfo("somefilepath").FileVersion

Or as noted here on a list of files:

get-childitem * -include *.dll,*.exe | foreach-object { "{0}`t{1}" -f $_.Name, [System.Diagnostics.FileVersionInfo]::GetVersionInfo($_).FileVersion }

Or even nicer as a script: http://jtruher.spaces.live.com/blog/cns!7143DA6E51A2628D!125.entry

这篇关于在PowerShell中获取文件版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆