Update check-ram.ps1

This commit is contained in:
Markus Fleschutz 2022-10-13 19:51:02 +02:00
parent 83d205e717
commit ce16c33272

View File

@ -41,22 +41,26 @@ function GetRAMType { param([int]$Type)
} }
try { try {
$Banks = Get-WmiObject -Class Win32_PhysicalMemory if ($IsLinux) {
foreach ($Bank in $Banks) { # TODO
$Capacity = $Bank.Capacity / (1024 * 1024 * 1024) } else {
$Type = GetRAMType $Bank.SMBIOSMemoryType $Banks = Get-WmiObject -Class Win32_PhysicalMemory
$Speed = $Bank.Speed foreach ($Bank in $Banks) {
[float]$Voltage = $Bank.ConfiguredVoltage / 1000.0 $Capacity = $Bank.Capacity / (1024 * 1024 * 1024)
$Vendor = $Bank.Manufacturer $Type = GetRAMType $Bank.SMBIOSMemoryType
if ("$($Bank.BankLabel)" -ne "") { $Speed = $Bank.Speed
$BankName = $Bank.BankLabel [float]$Voltage = $Bank.ConfiguredVoltage / 1000.0
} else { $Vendor = $Bank.Manufacturer
$BankName = $Bank.DeviceLocator if ("$($Bank.BankLabel)" -ne "") {
$Location = $Bank.BankLabel
} else {
$Location = $Bank.DeviceLocator
}
"$($Capacity)GB $Type ($($Speed)MHz, $($Voltage)V, $Vendor) in $Location bank."
} }
"$($Capacity)GB $Type ($($Speed)MHz, $($Voltage)V, $Vendor) in $BankName bank."
} }
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1 exit 1
} }