How to get free physical memory of remote computer using PowerShell

六月ゝ 毕业季﹏ 提交于 2020-06-25 12:18:33

问题


I have this:

(Get-WMIObject Win32_logicaldisk -computername computer).TotalPhysicalMemory

to get size of physical memory installed on remote computer. How do I get the FREE memory of that computer?

I've tried

(Get-WMIObject Win32_logicaldisk -computername computer).FreePhysicalMemory

and some other variants, but with no effect. Is there some list of possible "filters"?


回答1:


Whenever you want to see all of the properties of an object, pipe it to Format-List *.

Get-WmiObject Win32_LogicalDisk | format-list *
Get-WmiObject Win32_OperatingSystem | fl *

Or if you are looking for a particular propery, you can use wildcard search

Get-WmiObject Win32_OperatingSystem | fl *free*

As Aquinas says, you want the Win32_OperatingSystem class, FreePhysicalMemory property. Win32_LogicalDisk tracks hard disks, not RAM.




回答2:


You can also try the Get-Counter cmdlet:

(Get-Counter -Counter "\Memory\Available MBytes" -ComputerName computer).CounterSamples[0].CookedValue



回答3:


You want Win32_OperatingSystem not Win32_logicaldisk I believe.



来源:https://stackoverflow.com/questions/12250783/how-to-get-free-physical-memory-of-remote-computer-using-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!