# encoding: ascii # api: powershell # title: memory size # description: Very grateful to greg zakharov for this example. Good luck you, greg, in search of work. # version: 0.1 # type: function # author: greg zakharov # license: CC0 # function: Get-RamLength # x-poshcode-id: 5384 # x-archived: 2015-01-31T20:16:58 # x-published: 2015-08-27T11:39:00 # # function Get-RamLength { <# .NOTES Author: greg zakharov #> $raw = ( reg query "HKLM\HARDWARE\RESOURCEMAP\System Resources\Physical Memory" )[-1][-1..-8] for ($i = 1; $i -lt $raw.Length; $i++) { $ram += $raw[$i..($i - 1)] $i++ } '{0}Gb' -f [Math]::Round([Convert]::ToUInt32(-join $ram, 16) / 1Gb) }