Powershell get-item VersionInfo.ProductVersion 不正确/不同于 WMI [英] Powershell get-item VersionInfo.ProductVersion incorrect / different than WMI

查看:60
本文介绍了Powershell get-item VersionInfo.ProductVersion 不正确/不同于 WMI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图理解为什么 Powershell 会为 DLL 文件取回与 Windows 资源管理器中的文件属性页和 WMI 查询显示的版本号不同的版本号.(如果这不符合编码问题,我提前道歉.)

I'm trying to understand why Powershell would get back a different version number for a DLL file than what both the file properties page from Windows Explorer, and a WMI query shows. (I apologize in advance if this doesn't correctly qualify as a coding question.)

场景:

运行以下 powershell 命令:

Running the following powershell command:

(get-item C:\windows\system32\rdpcorekmts.dll).VersionInfo.ProductVersion

这将返回以下内容:

6.1.7600.16385

6.1.7600.16385

然而,这个版本号是不正确的.从 Windows 资源管理器检查版本信息时,您会看到以下版本(抱歉,我尝试发布它的小屏幕截图,但我没有足够的代表;我是新来的):

However, this version number is incorrect. When examining the version information from Windows Explorer, you see the following version (sorry, I tried posting a small screenshot of it, but I don't have enough rep; I'm new here):

6.1.7601.17767

6.1.7601.17767

此外,WMIC 查询显示的结果与 Windows 资源管理器相同:

In addition, a WMIC query shows the same results as Windows Explorer:

WMIC path CIM_DataFile WHERE (name="c:\\windows\\system32\\rdpcorekmts.dll") get Version

WMIC 结果:

版本

6.1.7601.17767

6.1.7601.17767

我真的不明白为什么他们会有所不同.我真的很想使用 Powershell 返回这个值,但现在我不确定我是否只是忽略了某些东西,或者我是否遇到了某种奇怪的错误,但是这两种方法之间的版本不匹配令人困惑.请注意,我在 Powershell 中对方法进行了修改(例如 Get-ItemChild 和 Get-ItemProperty),但得到了相同的错误版本结果.

I really don't understand why they would be different. I would really like to return this value using Powershell, but now I'm not sure if I'm just overlooking something, or if I ran across some kind of odd bug, but the version mismatch between the two methods is confusing. As a note, I've run variations on the method to get this back in Powershell (e.g. Get-ItemChild and Get-ItemProperty), and I get the same incorrect version result.

对原因有什么想法吗?

推荐答案

问题是您使用的 ProductVersion 属性似乎在某处进行了硬编码,IE 和 WMI 只是在产品中构建版本来自:

The problem is that you are using the ProductVersion propertie which seems to be hard coded somewhere, IE and WMI are just buildind the product version from :

ProductMajorPart   : 6
ProductMinorPart   : 1
ProductBuildPart   : 7601
ProductPrivatePart : 17767

FileVersion 相同,包括:FileMajorPart、FileMinorPart、FileBuildPart、FilePrivatePart

Same for FileVersion with : FileMajorPart, FileMinorPart, FileBuildPart, FilePrivatePart

试试吧:

(get-item C:\windows\system32\rdpcorekmts.dll).VersionInfo | fl *

你可以测试:

(get-item C:\windows\system32\rdpcorekmts.dll).VersionInfo | % {("{0}.{1}.{2}.{3}" -f $_.ProductMajorPart,$_.ProductMinorPart,$_.ProductBuildPart,$_.ProductPrivatePart)}

从 CMD.EXE 你可以试试:

From CMD.EXE you can try :

C:\>powershell -command "&{(get-item C:\windows\system32\rdpcorekmts.dll).VersionInfo | % {write-host ('{0}.{1}.{2}.{3}' -f $_.ProductMajorPart,$_.ProductMinorPart,$_.ProductBuildPart,$_.ProductPrivatePart)}}"

这篇关于Powershell get-item VersionInfo.ProductVersion 不正确/不同于 WMI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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