Microsoft网站参考
以下 ChassisTypes 列表是从最新的 DMTF SMBIOS 规范复制的。
# Set-ExecutionPolicy or Script Signing documentation needs to be reviewed
# Current script is designed to run on individual machines
#
#
$ChassisTypes =
@{
1='Other'
2='Unknown'
3='Desktop'
4='Low Profile Desktop'
5='Pizza Box'
6='Mini Tower'
7='Tower'
8='Portable'
9='Laptop'
10='Notebook'
11='Hand Held'
12='Docking Station'
13='All in One'
14='Sub Notebook'
15='Space-Saving'
16='Lunch Box'
17='Main System Chassis'
18='Expansion Chassis'
19='SubChassis'
20='Bus Expansion Chassis'
21='Peripheral Chassis'
22='Storage Chassis'
23='Rack Mount Chassis'
24='Sealed-Case PC'
25='Multi-system chassis'
26='Compact PCI'
27='Advanced TCA'
28='Blade'
29='Blade Enclosure'
30='Tablet'
31='Convertible'
32='Detachable'
33='IoT Gateway'
34='Embedded PC'
35='Mini PC'
36='Stick PC'
}
$namespace = "root\CIMV2"
$machines = New-Object System.Collections.ArrayList
# TODO: add code to populate the machine list from user input, etc.
#
$machines.Add("LocalHost") | Out-Null
$list = New-Object System.Collections.ArrayList
foreach ($machine in $machines)
{
$obj = New-Object -Type PSObject | Select-Object SerialNumber, Manufacturer, UUID, BaseBoardProduct, ChassisTypes, Chassis, SystemFamily, SystemSKUNumber
$obj.SerialNumber = Get-WmiObject -class Win32_Bios -computername $machine -namespace $namespace | Select-Object -ExpandProperty SerialNumber
$obj.Manufacturer = Get-WmiObject -class Win32_Bios -computername $machine -namespace $namespace | Select-Object -ExpandProperty Manufacturer
$obj.UUID = Get-WmiObject Win32_ComputerSystemProduct | Select-Object -ExpandProperty UUID
$obj.BaseBoardProduct = Get-WmiObject Win32_BaseBoard | Select-Object -ExpandProperty Product
$obj.ChassisTypes = Get-WmiObject Win32_SystemEnclosure | Select-Object -ExpandProperty ChassisTypes
$obj.Chassis = $ChassisTypes[[int]$obj.ChassisTypes]
$obj.SystemFamily = Get-WmiObject Win32_ComputerSystem | Select-Object -ExpandProperty SystemFamily
$obj.SystemSKUNumber = Get-WmiObject Win32_ComputerSystem | Select-Object -ExpandProperty SystemSKUNumber
$list.Add($obj) | Out-Null
}
# TODO: add code to handle output (save to local file, upload to share, etc.)
#
# to use on single line for each object
# $list | Sort-Object Manufacturer, Chassis | Format-Table Manufacturer, ChassisTypes, Chassis, SystemFamily, BaseBoard_Product, SerialNumber, UUID, SystemSKUNumber -Wrap
# Optional: pipe to Excel:
# $list | Export-Csv c:\path\filename.csv -Encoding Unicode -NoTypeInformation
#
# Optional: pipe to UI
# $list | Out-GridView
#
$list
这个是利用Get-WmiObject(别名gwmi)命令来获取的,输入gwmi –class win32_bios 或 gwmi –class win32_bios smbiosbiosversion获取BIOS版本信息(两种命令显示的方式和信息不一样)回车执行。
运行脚本时可能出现的问题:
PowerShell:因为在此系统上禁止运行脚本,解决方法
在自己编PowerShell脚本的时候突然遇到这个问题:
无法加载文件 C:\Users\DH\Desktop\cs\rename.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
CategoryInfo : SecurityError: ( [],ParentContainsErrorRecordException
FullyQualifiedErrorId : UnauthorizedAccess
查了查之后发现是在计算机上启动 Windows PowerShell 时,执行策略很可能是 Restricted(默认设置)。
Restricted 执行策略不允许任何脚本运行。
AllSigned 和 RemoteSigned 执行策略可防止 Windows PowerShell 运行没有数字签名的脚本。
本主题说明如何运行所选未签名脚本(即使在执行策略为 RemoteSigned 的情况下),还说明如何对 脚本进行签名以便您自己使用。
有关 Windows PowerShell 执行策略的详细信息,请参阅 about_Execution_Policy。
想了解 计算机上的现用执行策略,打开PowerShell 然后输入 get-executionpolicy。
以管理员身份打开PowerShell 输入 set-executionpolicy remotesigned
选择Y 然后电脑上就可以执行自己编写的脚本文件
windows系统: 使用命令行 获取 主板BIOS基本信息.2021-02-10
wmic BIOS get name,manufacturer,version,serialnumber,releasedate,currentlanguage,description
推荐 Windows 下读取 SMBIOS的工具
具体原理是使用: GetSystemFirmwareTable 来获得系统的SMBIOS信息。其中还有SMBIOS结构体的解析代码。有需要的朋友可以参考一下。
具体代码来自:https://github.com/KunYi/DumpSMBIOS