2022-10-12 16:22:05 +02:00
|
|
|
|
<#
|
|
|
|
|
.SYNOPSIS
|
|
|
|
|
Checks the RAM
|
|
|
|
|
.DESCRIPTION
|
|
|
|
|
This PowerShell script queries and prints details of the installed RAM.
|
|
|
|
|
.EXAMPLE
|
|
|
|
|
PS> ./check-ram
|
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
.NOTES
|
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
function GetRAMType { param([int]$Type)
|
|
|
|
|
switch($Type) {
|
|
|
|
|
2 { return "DRAM" }
|
2022-12-12 18:37:20 +01:00
|
|
|
|
5 { return "EDO" }
|
2022-10-12 16:22:05 +02:00
|
|
|
|
6 { return "EDRAM" }
|
|
|
|
|
7 { return "VRAM" }
|
|
|
|
|
8 { return "SRAM" }
|
|
|
|
|
10 { return "ROM" }
|
2022-12-12 18:37:20 +01:00
|
|
|
|
11 { return "Flash" }
|
2022-10-12 16:22:05 +02:00
|
|
|
|
12 { return "EEPROM" }
|
|
|
|
|
13 { return "FEPROM" }
|
|
|
|
|
14 { return "EPROM" }
|
|
|
|
|
15 { return "CDRAM" }
|
|
|
|
|
16 { return "3DRAM" }
|
|
|
|
|
17 { return "SDRAM" }
|
|
|
|
|
18 { return "SGRAM" }
|
|
|
|
|
19 { return "RDRAM" }
|
2022-12-12 18:37:20 +01:00
|
|
|
|
20 { return "DDR" }
|
|
|
|
|
21 { return "DDR2" }
|
2022-10-12 16:22:05 +02:00
|
|
|
|
22 { return "DDR2 FB-DIMM" }
|
2022-12-12 18:37:20 +01:00
|
|
|
|
24 { return "DDR3" }
|
|
|
|
|
26 { return "DDR4" }
|
|
|
|
|
27 { return "DDR5" }
|
|
|
|
|
28 { return "DDR6" }
|
|
|
|
|
29 { return "DDR7" }
|
2022-10-12 16:22:05 +02:00
|
|
|
|
default { return "RAM" }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-12 18:37:20 +01:00
|
|
|
|
function Bytes2String { param([int64]$Bytes)
|
|
|
|
|
if ($Bytes -lt 1000) { return "$Bytes bytes" }
|
|
|
|
|
$Bytes /= 1000
|
|
|
|
|
if ($Bytes -lt 1000) { return "$($Bytes)KB" }
|
|
|
|
|
$Bytes /= 1000
|
|
|
|
|
if ($Bytes -lt 1000) { return "$($Bytes)MB" }
|
|
|
|
|
$Bytes /= 1000
|
|
|
|
|
if ($Bytes -lt 1000) { return "$($Bytes)GB" }
|
|
|
|
|
$Bytes /= 1000
|
|
|
|
|
if ($Bytes -lt 1000) { return "$($Bytes)TB" }
|
|
|
|
|
$Bytes /= 1000
|
|
|
|
|
if ($Bytes -lt 1000) { return "$($Bytes)PB" }
|
|
|
|
|
$Bytes /= 1000
|
|
|
|
|
if ($Bytes -lt 1000) { return "$($Bytes)EB" }
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-12 16:22:05 +02:00
|
|
|
|
try {
|
2022-10-13 19:51:02 +02:00
|
|
|
|
if ($IsLinux) {
|
|
|
|
|
# TODO
|
|
|
|
|
} else {
|
|
|
|
|
$Banks = Get-WmiObject -Class Win32_PhysicalMemory
|
|
|
|
|
foreach ($Bank in $Banks) {
|
2022-12-12 18:37:20 +01:00
|
|
|
|
$Capacity = Bytes2String($Bank.Capacity)
|
2022-10-13 19:51:02 +02:00
|
|
|
|
$Type = GetRAMType $Bank.SMBIOSMemoryType
|
|
|
|
|
$Speed = $Bank.Speed
|
|
|
|
|
[float]$Voltage = $Bank.ConfiguredVoltage / 1000.0
|
2022-10-16 09:16:43 +02:00
|
|
|
|
$Manufacturer = $Bank.Manufacturer
|
2022-10-26 10:34:07 +02:00
|
|
|
|
$Location = "$($Bank.BankLabel)/$($Bank.DeviceLocator)"
|
2022-12-12 18:37:20 +01:00
|
|
|
|
"✅ RAM $Capacity at $Location ($Type, $($Speed)MHz, $($Voltage)V, $Manufacturer)"
|
2022-10-13 19:42:55 +02:00
|
|
|
|
}
|
2022-10-12 16:22:05 +02:00
|
|
|
|
}
|
|
|
|
|
exit 0 # success
|
|
|
|
|
} catch {
|
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
|
|
|
exit 1
|
2022-10-26 10:34:07 +02:00
|
|
|
|
}
|