Skip to content

Commit

Permalink
update hw_report
Browse files Browse the repository at this point in the history
  • Loading branch information
a1ive committed Nov 14, 2024
1 parent 7e21ca9 commit fb2c064
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions hw_report.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
# SPDX-License-Identifier: Unlicense

[Console]::OutputEncoding = [System.Text.Encoding]::UTF8

$programPath = ".\nwinfo.exe"
$programArgs = @("--format=json",
Expand All @@ -8,14 +10,25 @@ $programArgs = @("--format=json",
"--cpu",
"--smbios",
"--net=phys",
"--disk=no-smart",
"--disk=no-smart,phys",
"--audio"
)

$processOutput = & $programPath $programArgs

$parsedJson = $processOutput | ConvertFrom-Json

$dmiTable = @{}
foreach ($smbiosTable in $parsedJson.'SMBIOS') {
$tableType = $smbiosTable.'Table Type'
if ($tableType -ne $null) {
if (-not $dmiTable.ContainsKey($tableType)) {
$dmiTable[$tableType] = @()
}
$dmiTable[$tableType] += $smbiosTable
}
}

Write-Output "OS:"
$systemTable = $parsedJson.'System'
Write-Output "`t$($systemTable.'Os')"
Expand All @@ -28,10 +41,32 @@ Write-Output "`t$($cpuTable.'Brand')"
Write-Output "`t`t$($cpuTable.'Code Name')"
Write-Output "`t`t$($cpuTable.'Cores') cores $($cpuTable.'Logical CPUs') threads"
Write-Output "`t`t$($cpuTable.'Temperature (C)') °C"
if ($null -ne $dmiTable[4]) {
Write-Output "`t`t$($dmiTable[4][0].'Socket Designation') socket"
}

Write-Output "RAM:"
$maxCapacity = "unknown"
$numSlots = "unknown"
if ($null -ne $dmiTable[16]) {
$maxCapacity = $dmiTable[16][0].'Max Capacity'
$numSlots = $dmiTable[16][0].'Number of Slots'
} elseif ($null -ne $dmiTable[5]) {
$maxCapacity = "$($dmiTable[5][0].'Max Memory Module Size (MB)') MB"
$numSlots = $dmiTable[5][0].'Number of Slots'
}
Write-Output "`tMax Capacity $maxCapacity $numSlots slots"
if ($null -ne $dmiTable[17]) {
foreach ($mdTable in $dmiTable[17]) {
Write-Output "`t$($mdTable.'Device Type')-$($mdTable.'Speed (MT/s)') $($mdTable.'Device Size') $($mdTable.'Manufacturer')"
Write-Output "`t`t$($mdTable.'Device Locator') $($mdTable.'Bank Locator') $($mdTable.'Form Factor')"
Write-Output "`t`t$($mdTable.'Serial Number') $($mdTable.'Part Number')"
}
}

Write-Output "Network:"
foreach ($net in $parsedJson.'Network') {
Write-Output "`t$($net.'Description')"
foreach ($netTable in $parsedJson.'Network') {
Write-Output "`t$($netTable.'Description')"
}

Write-Output "Disk:"
Expand All @@ -45,6 +80,7 @@ foreach ($diskTable in $parsedJson.'Disks') {
$diskType = "SSD"
}
Write-Output "`t`t$($diskTable.'Size') $diskType $($diskTable.'Type')"
Write-Output "`t`t$($diskTable.'Serial Number')"
}

Write-Output "Audio:"
Expand Down

0 comments on commit fb2c064

Please sign in to comment.