本帖最后由 meixi 于 2024-8-11 21:40 编辑
如何通过powershell中的wmi相关命令判断硬盘类型, 和内存类型, 例如:
硬盘类型: sata, nvme
内存类型: ddr2, ddr3, ddr4
用ai都没有答对:- # 硬盘类型
- Get-WmiObject -Class Win32_DiskDrive | Select-Object Model, InterfaceType
- # 内存类型
- Get-WmiObject -Class Win32_PhysicalMemory | ForEach-Object {
- $memoryType = switch ($_.SMBIOSMemoryType) {
- 20 { "DDR" }
- 21 { "DDR2" }
- 22 { "DDR2 FB-DIMM" }
- 24 { "DDR3" }
- 26 { "DDR4" }
- Default { "Unknown" }
- }
- [PSCustomObject]@{
- Manufacturer = $_.Manufacturer
- Capacity = ($_.Capacity / 1GB) -as [int]
- MemoryType = $memoryType
- }
- }
复制代码 |