PoshCode Archive  Artifact [04451effe4]

Artifact 04451effe45042249441a28db11dcafb9ce0e58b18828a15dea50a6aca634d49:

  • File PS-Get-RAM-size.ps1 — part of check-in [cc5e18dbb4] at 2018-06-10 13:43:06 on branch trunk — Get the capacity of your installed RAM with the Win32_PhysicalMemory WMI class. (user: Florian Frank size: 726)

# encoding: ascii
# api: powershell
# title: PS: Get RAM size
# description: Get the capacity of your installed RAM with the Win32_PhysicalMemory WMI class.
# version: 0.1
# type: class
# author: Florian Frank
# license: CC0
# x-poshcode-id: 4565
# x-archived: 2016-04-20T01:36:58
# x-published: 2016-10-27T22:22:00
#
#
# Type long (64-bit integer) is necessary because the WMI class state the capacity in byte --> might be too long for int32 ;-)
[long]$memory = 0

# Get the WMI class Win32_PhysicalMemory and total the capacity of all installed memory modules
Get-WmiObject -Class Win32_PhysicalMemory | ForEach-Object -Process { $memory += $_.Capacity }

# Display the output in Gigabyte
$memory / 1GB