Posted On November 22, 2022

PowerShell: Get Available RAM Slots

kimconnect 0 comments
blog.KimConnect.com >> Codes , Windows >> PowerShell: Get Available RAM Slots
# getRamSlotsAvailable.ps1

$computername=$env:computername

function getRamSlotsAvailable{
    param($computername=$env:computername)
    write-host "Computer name: $computerName"
    $slots = Get-WmiObject -Class "win32_PhysicalMemoryArray" -namespace "root\CIMV2" -computerName $computerName
    $ramModules = Get-WmiObject -Class "win32_PhysicalMemory" -namespace "root\CIMV2" -computerName $computerName
    $ramSum=0
    $ramModules.Capacity|%{$ramSum+=$_}
    $slotsSum=0
    $slots.MemoryDevices|%{$slotsSum+=$_}
    write-host "Total slots: $slotsSum"
    write-host "Total RAM: $([math]::round($ramSum/1GB,2)) GB"
    Foreach ($module In $ramModules) {
        write-host "Memory Installed: $($module.DeviceLocator)"
        write-host "Memory Size: $($module.Capacity/1GB) GB"
    }
    return $slotsSum
}

getRamSlotsAvailable $computername

# Sample output
# PS C:\Windows\system32> getRamSlotsAvailable $computername
# Computer name: TEST-SERVER
# Total slots: 24
# Total RAM: 256 GB
# Memory Installed: DIMM_A1
# Memory Size: 16 GB
# Memory Installed: DIMM_A2
# Memory Size: 16 GB
# Memory Installed: DIMM_A3
# Memory Size: 16 GB
# Memory Installed: DIMM_A4
# Memory Size: 16 GB
# Memory Installed: DIMM_A5
# Memory Size: 16 GB
# Memory Installed: DIMM_A6
# Memory Size: 16 GB
# Memory Installed: DIMM_A7
# Memory Size: 16 GB
# Memory Installed: DIMM_A8
# Memory Size: 16 GB
# Memory Installed: DIMM_B1
# Memory Size: 16 GB
# Memory Installed: DIMM_B2
# Memory Size: 16 GB
# Memory Installed: DIMM_B3
# Memory Size: 16 GB
# Memory Installed: DIMM_B4
# Memory Size: 16 GB
# Memory Installed: DIMM_B5
# Memory Size: 16 GB
# Memory Installed: DIMM_B6
# Memory Size: 16 GB
# Memory Installed: DIMM_B7
# Memory Size: 16 GB
# Memory Installed: DIMM_B8
# Memory Size: 16 GB

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Create and Edit SMB Shares

# Create SMB Share $sharePath='C:\testshare' $accessList="$env:USERDOMAIN\Domain Admins","NT AUTHORITY\Authenticated Users" $shareName=split-path $sharePath -leaf mkdir $sharePath New-SmbShare…

Basic CSS: Add Different Padding to Each Side of an Element

<style>.injected-text {margin-bottom: -25px;text-align: center;}.box {border-style: solid;border-color: black;border-width: 5px;text-align: center;}.yellow-box {background-color: yellow;padding: 10px;}.red-box {background-color: crimson;color: #fff;padding-top:…

Basic CSS: Add Rounded Corners with border-radius

<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css"><style>.red-text {color: red;}h2 {font-family: Lobster, monospace;}p {font-size: 16px;font-family: monospace;}.thick-green-border {border-color: green;border-width: 10px;border-style:…