PoshCode Archive  Artifact [e87fc7099f]

Artifact e87fc7099fa767504972edcde6a023a1e1802d110ce556edba7560688f3d4c05:

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

# encoding: ascii
# api: powershell
# title: Determine capacity of RA
# 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: 4564
# x-derived-from-id: 4565
# x-archived: 2015-10-25T13:42:35
# x-published: 2015-10-27T22:21: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