Here's an easy way to get those values:
$computers = @(".")
Foreach ($computer in $computers){
[PSCustomObject]@{
'PhysicalMemory (bytes)' = ((((Get-CimInstance Win32_PhysicalMemory -ComputerName $computer).Capacity) | Measure-Object -Sum).Sum) # bytes
'FreePhysicalMemory (bytes)' = (((Get-CIMInstance Win32_OperatingSystem -ComputerName $computer).FreePhysicalMemory) * 1024) # convert kilobytes to bytes
}
}
If you have a very large number of machines to query this doesn't offer possibility of performing the work in parallel, so it may not be what you need.
For parallelism you could package the two Get-CimObject cmdlets in a scriptblock and use the scriptblock in an Invoke-Command with the $computers list as the value for -ComputerName. That will return an array of PSCustomObjects. But it does complicate processing because there may be machines that are not available and those would result in ErrorRecord objects in the results.