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

[玩转系统] Get-ComputerInfo - 获取计算机的多个属性

作者:精品下载站 日期:2024-12-14 17:01:17 浏览:13 分类:玩电脑

Get-ComputerInfo - 获取计算机的多个属性


获取计算机多个属性(例如制造商、BIOS 信息等)的命令是 PowerShell 中的 Get-ComputerInfo cmdlet。

PowerShell 中的 Get-ComputerInfo cmdlet 检索计算机硬件信息,例如制造商、型号、处理器数量、网络适配器、BIOS 信息(例如 Bios 版本、Bios 固件类型、操作系统信息)操作系统制造商、操作系统安装日期、RAM 配置、操作系统序列号数量等等。

在 PowerShell 中,Get-WMIObject 和 Get-CIMInstance cmdlet 获取计算机的多个属性和系统信息。管理员多年来使用这些命令来获取计算机信息,但它需要记住 wmi/cim 类才能获取特定的计算机属性。

Get-ComputerInfo cmdlet 无需任何参数即可检索所有计算机属性。目前,Get-ComputerInfo cmdlet 返回大约。 Windows 10 操作系统中的 182 个属性和 4 个方法。

Get-ComputerInfo 使用 Get-Member cmdlet 返回属性成员类型和定义,如下所示

[玩转系统] Get-ComputerInfo - 获取计算机的多个属性

让我们通过更多示例来了解 PowerShell 中的 Get-ComputerInfo cmdlet,以获取计算机的多个属性、获取有关远程计算机的计算机信息、获取远程计算机的操作系统版本等等...

Get-ComputerInfo 多个属性

从本地计算机获取计算机信息的命令是 Get-ComputerInfo cmdlet。此命令检索计算机信息的多个属性,例如获取操作系统名称、获取计算机的操作系统版本、操作系统语言。

Get-ComputerInfo | Select OSName, OSVersion, OSLastBootupTime,OSLanguage  

在上面获取计算机信息的PowerShell脚本中,它得到

OSName - 获取计算机的操作系统名称

OsVersion - 获取计算机的操作系统版本

OSLastBootupTime - 获取计算机上次启动时间

OSLanguage - 获取系统的操作系统语言

上述 PowerShell 脚本的输出如下。

PS C:\> Get-ComputerInfo | Select OSName, OSVersion, OSLastBootupTime,OSLanguage                                        
OsName                   OsVersion  OsLastBootUpTime    OsLanguage
------                   ---------  ----------------    ----------
Microsoft Windows 10 Pro 10.0.18363 03-08-2021 11:18:21 en-US


PS C:\>     

酷提示:您知道哪些动词在 PowerShell 中是认可的吗?

使用 PowerShell 获取系统信息

获取系统信息的powershell命令是Get-ComputerInfo。

Get-ComputerInfo

在上面的脚本中,PowerShell 命令 Get-ComputerInfo 获取系统信息并将其显示在终端上。

[玩转系统] Get-ComputerInfo - 获取计算机的多个属性

酷提示:如何在 PowerShell 中获取计算机的序列号!

Get-ComputerInfo - 获取系统的 BIOS 属性

使用命令Get-ComputerInfo 获取系统的BIOS 属性。

Get-ComputerInfo -Property *BIOS*

在上面的 PowerShell 脚本中,Get-ComputerInfo 使用通配符来选择 BIOS 属性,例如 Bios 制造商、Bios 名称、BiosVersion

上述命令的输出如下。

PS C:\> Get-ComputerInfo -Property *BIOS*


BiosCharacteristics                : {7, 9, 11, 12...}
BiosBIOSVersion                    : {DELL   - 1072009, 1.8.2, American Megatrends - 5000B}
BiosBuildNumber                    :
BiosCaption                        : 1.8.2
BiosCodeSet                        :
BiosCurrentLanguage                : en|US|iso8859-1
BiosDescription                    : 1.8.2
BiosEmbeddedControllerMajorVersion : 255
BiosEmbeddedControllerMinorVersion : 255
BiosFirmwareType                   : Uefi
BiosIdentificationCode             :
BiosInstallableLanguages           : 2
BiosInstallDate                    :
BiosLanguageEdition                :
BiosListOfLanguages                : {en|US|iso8859-1, }
BiosManufacturer                   : Dell Inc.
BiosName                           : 1.8.2
BiosOtherTargetOS                  :
BiosPrimaryBIOS                    : True
BiosReleaseDate                    : 03-04-2019 05:30:00
BiosSeralNumber                    : ADVC3X2
BiosSMBIOSBIOSVersion              : 1.8.2
BiosSMBIOSMajorVersion             : 3
BiosSMBIOSMinorVersion             : 1
BiosSMBIOSPresent                  : True
BiosSoftwareElementState           : Running
BiosStatus                         : OK
BiosSystemBiosMajorVersion         : 1
BiosSystemBiosMinorVersion         : 8
BiosTargetOperatingSystem          : 0
BiosVersion                        : DELL   - 1072009

酷提示:如何获取 PowerShell 模块列表!

获取远程计算机的计算机信息

要从远程计算机获取系统信息,请使用 Invoke-Cmdlet,它具有 ComputerName 参数来指定一台或多台远程计算机名称。它使用Get-ComputerInfo来获取远程计算机信息。

Invoke-Command -ComputerName 'incorp-eu-01' -ScriptBlock { Get-ComputerInfo -Property "OS*" }  

在上面的 PowerShell 脚本中,Invoke-Command cmdlet 使用远程计算机名称运行命令,获取命令的输出,并使用 Get-ComputerInfo 获取操作系统信息在远程系统上。

如果要从多台计算机获取系统信息或网络信息,请指定远程计算机名称,以逗号(,)分隔,如下所示

Invoke-Command -ComputerName 'incorp-eu-01','incorp-eu-02' -ScriptBlock { Get-ComputerInfo -Property "OS*" }  

酷提示:如何在 PowerShell 中重命名计算机!

结论

希望以上文章介绍使用PowerShell Get-ComputerInfo获取多台服务器的系统信息,获取远程系统的系统信息、BIOS信息或OS信息。

PowerShell 中的 Get-ComputerInfo cmdlet 对于检索所有计算机属性非常有用,无需使用任何参数。

酷提示:如何在 PowerShell 中获取 Mac 地址!

您可以在 ShellGeek 主页上找到有关 PowerShell Active Directory 命令和 PowerShell 基础知识的更多主题。

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

取消回复欢迎 发表评论:

关灯