如何使用PowerShell获得远程计算机的空闲物理内存

我有这个:

(Get-WMIObject Win32_logicaldisk -computername computer).TotalPhysicalMemory 

以获得安装在远程计算机上的物理内存的大小。 如何获得该计算机的免费内存?

我试过了

 (Get-WMIObject Win32_logicaldisk -computername computer).FreePhysicalMemory 

和其他一些变种,但没有效果。 是否有一些可能的“filter”列表?

您也可以尝试Get-Counter cmdlet:

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

每当你想看到一个对象的所有属性,将其管道到Format-List *

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

或者如果你正在寻找一个特定的propery,你可以使用通配符搜索

 Get-WmiObject Win32_OperatingSystem | fl *free* 

正如Aquinas所说,你需要Win32_OperatingSystem类, FreePhysicalMemory属性。 Win32_LogicalDisk跟踪硬盘,而不是RAM。

你想Win32_OperatingSystem不是Win32_logicaldisk我相信。