Windows 如何使用PowerShell获取远程计算机的可用物理内存

Windows 如何使用PowerShell获取远程计算机的可用物理内存,windows,powershell,memory-management,powershell-remoting,Windows,Powershell,Memory Management,Powershell Remoting,我有这个: (Get-WMIObject Win32_logicaldisk -computername computer).TotalPhysicalMemory 获取远程计算机上安装的物理内存的大小。 我怎样才能得到那台计算机的空闲内存 我试过了 (Get-WMIObject Win32_logicaldisk -computername computer).FreePhysicalMemory 和其他一些变体,但没有效果。是否有一些可能的“过滤器”列表?我相信您想要的是Win32\u操

我有这个:

(Get-WMIObject Win32_logicaldisk -computername computer).TotalPhysicalMemory
获取远程计算机上安装的物理内存的大小。 我怎样才能得到那台计算机的空闲内存

我试过了

(Get-WMIObject Win32_logicaldisk -computername computer).FreePhysicalMemory

和其他一些变体,但没有效果。是否有一些可能的“过滤器”列表?

我相信您想要的是
Win32\u操作系统
而不是
Win32\u逻辑磁盘

每当您想查看对象的所有属性时,将其导入
格式列表*

Get-WmiObject Win32_LogicalDisk | format-list *
Get-WmiObject Win32_OperatingSystem | fl *
或者,如果要查找特定属性,可以使用通配符搜索

Get-WmiObject Win32_OperatingSystem | fl *free*

正如Aquinas所说,您需要
Win32_OperatingSystem
类,
FreePhysicalMemory
属性
Win32\u LogicalDisk
跟踪硬盘,而不是RAM。

您也可以尝试使用
Get Counter
cmdlet:

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

因此,把其他答案放在一起:

get-ciminstance Win32_OperatingSystem | % FreePhysicalMemory
远程:

invoke-command computer { get-ciminstance Win32_OperatingSystem | % FreePhysicalMemory } 

本地计算机的可用内存(远程计算机使用
-computername foo
):


用1MB除以GB可能看起来很奇怪,但原始数字只是以KB表示的。结果实际上与编写
*1KB/1GB
(您也可以使用)没有什么不同。

如果他实际上指的是磁盘空间,那么属性将是
Size
FreeSpace
。我相信这真的应该是
获取CimInstance Win32\u OperatingSystem
Get-WmiObject
自PowerShell 3.x起被弃用,自PowerShell 6.x起被删除。@TheFreeman193 Ok。
(Get-WMIObject Win32_OperatingSystem).FreePhysicalMemory  # in KB

19793740
(Get-WMIObject Win32_OperatingSystem).FreePhysicalMemory / 1MB  # in GB

18.8592491149902