I'm trying to get the physical memory size using PowerShell, but without using get-wmiobject.
I have been using the following PS cmdlet to get the physical memory size, but the value changes with each new poll.
(get-counter -counter "\Memory\Available Bytes").CounterSamples.CookedValue +
(get-counter -counter "\Memory\Committed Bytes").CounterSamples.CookedValue
(get-wmiobject -class "win32_physicalmemory" -namespace "root\CIMV2").Capacity
If you don't want to use WMI, I can suggest systeminfo.exe. But, there may be a better way to do that.
(systeminfo | Select-String 'Total Physical Memory:').ToString().Split(':').Trim()