当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 在 PowerShell 中获取驱动程序版本 [2 种方式]

作者:精品下载站 日期:2024-12-14 05:23:44 浏览:15 分类:玩电脑

在 PowerShell 中获取驱动程序版本 [2 种方式]


使用 WMI 对象的 win32_PnpSignedDriver 类

要在 PowerShell 中获取驱动程序版本,请使用 WMI 对象的 win32_PnpSignedDriver 类。

在 PowerShell 中获取驱动程序版本:

Get-WmiObject Win32_PnPSignedDriver| select Devicename, Driverversion, Description

运行该命令后,您的 PowerShell 应该会给出如下输出:

[玩转系统] 在 PowerShell 中获取驱动程序版本 [2 种方式]

请注意各列如何排列为“设备名称”、“设备版本”和“说明”。如果您以任何顺序编写命令,结果将相同,但顺序会改变。如果您以不同的顺序编写,则输出如下:

[玩转系统] 在 PowerShell 中获取驱动程序版本 [2 种方式]

为了简单起见,您可以进一步自定义命令。例如,使用以下命令删除 Description

在 PowerShell 中获取驱动程序版本:

Get-WmiObject Win32_PnPSignedDriver| SELECT Devicename, Driverversion

或者

在 PowerShell 中获取驱动程序版本:

gwmi Win32_PnPSignedDriver| SELECT Devicename, Driverversion

什么是 Get-WmiObject?

WMI 的意思是“Windows 管理规范”。 Get-wmi cmdlet 用于检索有关可用 WMI 类以及 WMI 类实例的信息。

使用 Get-CimInstance cmdlet

如果您拥有 PowerShell 6.0 或更高版本,您还可以使用 Get-CimInstance cmdlet 代替 Get-WmiObject
首先,使用以下命令检查您的 PowerShell 版本:

在 PowerShell 中获取驱动程序版本:

$PSVersionTable

您可以从以下输出中检查您的版本详细信息:

[玩转系统] 在 PowerShell 中获取驱动程序版本 [2 种方式]

在 PowerShell 中获取驱动程序版本:

Get-CimInstance win32_PnpSignedDriver

或者

在 PowerShell 中获取驱动程序版本:

gcim win32_PnpSignedDriver

您的 PowerShell 应显示类似的输出:

[玩转系统] 在 PowerShell 中获取驱动程序版本 [2 种方式]

在 PowerShell 中获取驱动程序版本:

gcim win32_PnpSignedDriver | SELECT Description, DriverVersion

[玩转系统] 在 PowerShell 中获取驱动程序版本 [2 种方式]

结论

PowerShell 本质上是一种任务自动化解决方案。由脚本语言、配置管理框架和命令行 shell 组成,您可以使用 PowerShell 检查有关设备的信息并执行其他功能。在本文中,我们学习了如何在 PowerShell 中获取驱动程序版本的两种方法。这些方法是 Get-WmiObject (gwmi) 和 Get-CimInstance (gcim)。

两者后跟 win32_PnpSignedDriver 来检索信息。您可以使用 SELECT 来检索描述和驱动程序版本来扩展此命令。
因此,以下是命令摘要:

Command Purpose Filters Get-WmiObject Win32_PnPSignedDriver Retrieve information on available WMI classes as well as instances of WMI classes. | select Devicename, Driverversion, Description gwmi Win32_PnPSignedDriver Same as above Same as above Get-CimInstance win32_PnpSignedDriver Retrieve information on CIM instances. In the end same data as WMI. | select Devicename, Driverversion, Description gcim win32_PnpSignedDriver Same as above Same as above $PSVersionTable Retrieve PowerShell Version information

这就是如何在 PowerShell 中获取驱动程序版本的全部内容。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯