Public/Hardware/Get-RAMInfo.ps1
<#
Copyright © 2024 Integris. For internal company use only. All rights reserved. #> FUNCTION Get-RAMInfo { <# .SYNOPSIS Retrieves and displays information about RAM modules installed in the system. .DESCRIPTION This function collects detailed information about each RAM module, including its capacity, type, clock speed, manufacturer, part number, and serial number. It also identifies empty memory slots and calculates the total memory installed. .EXAMPLE Get-RAMModule This command retrieves and displays information about all RAM modules installed in the system. .NOTES This function uses CIM instances to gather RAM module information and may require appropriate permissions to execute. #> [CmdletBinding()] PARAM ( ) $Results = @() $MemoryArray = Get-CIMInstance -Class "Win32_PhysicalMemoryArray" $MemoryModuleTotal = $MemoryArray.MemoryDevices $MemoryModuleCount = IF ($MemoryArray.MemoryErrorCorrection -eq 3) { $MemType = "Non-ECC" } ELSEIF ($MemoryArray.MemoryErrorCorrection -eq 5) { $MemType = "ECC" } ELSEIF ($MemoryArray.MemoryErrorCorrection -eq 6) { $MemType = "ECC" } ELSE { $MemType = "Unknown" } $Modules = Get-CIMInstance -Class "Win32_PhysicalMemory" $TotalMem = 0 FOREACH ($Module in $Modules) { $MemoryModuleCount++ IF ($Module.SMBIOSMemoryType -eq 21) { $DDRType = "DDR2" } ELSEIF ($Module.SMBIOSMemoryType -eq 24) { $DDRType = "DDR3" } ELSEIF ($Module.SMBIOSMemoryType -eq 26) { $DDRType = "DDR4" } ELSEIF ($Module.SMBIOSMemoryType -eq 34) { $DDRType = "DDR5" } ELSE { $DDRType = "Unknown" } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PSTypeName = 'IntegrisPowerShell.RAMInfo' BankLabel = $Module.DeviceLocator GBs = $Module.Capacity / 1GB DDRType = $DDRType ClockSpeed = $Module.ConfiguredClockSpeed Type = $MemType Manufacturer = $Module.Manufacturer PartNumber = $Module.PartNumber SerialNumber = $Module.SerialNumber } $TotalMem += $Module.Capacity / 1GB } While ($MemoryModuleCount -lt $MemoryModuleTotal) { $Results += New-Object PSCustomObject -WarningAction SilentlyContinue -Property @{ PSTypeName = 'IntegrisPowerShell.RAMInfo' BankLabel = "Empty Slot" GBs = "" DDRType = "" ClockSpeed = "" Type = "" Manufacturer = "" PartNumber = "" SerialNumber = "" } $MemoryModuleCount++ } $Results += New-Object PSCustomObject -WarningAction SilentlyContinue -Property @{ PSTypeName = 'IntegrisPowerShell.RAMInfo' BankLabel = "Total" GBs = $TotalMem DDRType = "" ClockSpeed = "" Type = "" Manufacturer = "" PartNumber = "" SerialNumber = "" } RETURN $Results } New-Alias -Name Get-RAMModule -Value Get-RAMInfo |