# encoding: ascii
# api: powershell
# title: Get-FreeRAM
# description: Get the Free RAM from a system
# version: 0.1
# type: function
# author: Joel Bennett
# license: CC0
# function: Get-FreeRam
# x-poshcode-id: 2962
# x-archived: 2011-11-05T18:06:22
# x-published: 2011-09-21T09:58:00
#
# I wrote this just to show how to write WMI functions that work on multiple computers β note the difference between this script and itβs predecessor is just which WMI object and property are being returned
#
function Get-FreeRam {
#.Synopsis
# Gets the FreePhysicalMemory from the specified computer(s)
#.Parameter ComputerName
# The name(s) of the computer(s) to get the Free Ram (FreePhysicalMemory) for.
#.Example
# Get-FreeRam SDI-JBennett, Localhost
#
# Computer FreePhysicalMemory
# -------- ------------------
# SDI-JBENNETT 4180364
# SDI-JBENNETT 4179764
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[string[]]$ComputerName='localhost'
)
process {
Get-WmiObject -ComputerName $ComputerName Win32_OperatingSystem |
Select-Object -Property @{name="Computer";expression={$_.__SERVER}}, FreePhysicalMemory
}
}