PoshCode Archive  Artifact Content

Artifact 43e65bdfbc7428744c767a5bc871899ae730df9d71cc10edf2a891b58a9a2142:

  • File memory-size.ps1 — part of check-in [ec53bbc8e0] at 2018-06-10 13:54:26 on branch trunk — Very grateful to greg zakharov for this example. Good luck you, greg, in search of work. (user: greg zakharov size: 722)

# 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)
}