Get-OMEDeviceRAM.ps1

function Get-OMEDeviceRAM {
    <#
    .SYNOPSIS
        Gets information about the device RAM.
 
    .DESCRIPTION
        Gets information about the device RAM.
        Alias for the Get-OMEDeviceInventory -Table 16
    .PARAMETER Id
        Query inventory for the device with the specific Id.
    .PARAMETER Name
        Query inventory for the device with the specific Name.
    .PARAMETER AssetTag
        Query inventory for the device with the specific Asset Tag.
    .PARAMETER ServiceTag
        Query inventory for the device with the specific Service Tag.
    .PARAMETER Session
        Specifies the Session Id for the OME server.
             
    .EXAMPLE
        Get-OMEDeviceRAM -Session $session -Name server45.example.com
 
        MemoryDeviceBankName : A
        MemoryDeviceSize : 8192
        MemoryDevicePartNumberName : 36KD59G2PZ-28DL
        MemoryDeviceIndex : 2
        MemoryDeviceType : DDR3
        MemoryDeviceSerialNumberName : XJ48F45
        MemoryDeviceTypeDetails : DDR3 DIMM
        MemoryDeviceName : DIMM.Socket.A2
        MemoryDeviceStatus : 0
        MemoryDeviceManufacturerName : Micron Technology
        DeviceId : 325
        MemoryDeviceChassisIndex : 1
         
    .NOTES
        Author: Mike Khar
    .LINK
        http://www.dell.com/support/home/us/en/04/product-support/product/dell-openmanage-essentials-v2.2/research
        https://$Server:$Port/api/OME.svc/$DeviceID/TableInventory/3
    #>
  

    [CmdletBinding(DefaultParametersetName="Id"
    )]
    Param(
        [parameter(Mandatory=$true,ParameterSetName="Id",ValueFromPipeline=$true)]
        $Id,
        [parameter(Mandatory=$true,ParameterSetName="Name")]
        [String]$Name,
        [parameter(Mandatory=$true,ParameterSetName="AssetTag")]
        [String]$AssetTag,
        [parameter(Mandatory=$true,ParameterSetName="ServiceTag")]
        [String]$ServiceTag,
        $Session="OMEConnection.DefaultOMESession"
    )
    
    Begin
    {
        $CurrentSession = Get-Variable -Scope Global -Name $Session -ErrorAction SilentlyContinue -ValueOnly
        If (!$CurrentSession) {
            Write-Warning "Please use Set-OMEConnection first"
            Break
            Return
        }
        else {
            $BaseUri="https://"+$CurrentSession.Server+":"+$CurrentSession.Port+"/api/OME.svc"
        }
    }
    
    Process
    {    
        $string="Get-OMEDeviceInventory -Session $Session -Table 16"
        if ($Id) {
            $string+=' -Id $Id'
        }
        if ($Name) {
            $string+=' -Name $Name'
        }
        if ($AssetTag) {
            $string+=' -AssetTag $AssetTag'
        }
        if ($ServiceTag) {
            $string+=' -ServiceTag $ServiceTag'
        }
        if ($Credentials) {
            $string+=' -Credentials $Credentials'
        }
        return Invoke-Expression $string
    }
    
    End{}
}