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"?
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.
您还可以尝试使用Get-Counter
cmdlet:
(Get-Counter -Counter "\Memory\Available MBytes" -ComputerName computer).CounterSamples[0].CookedValue
我相信你想要Win32_OperatingSystem
而不是Win32_logicaldisk
。
So putting together the other answers:
get-ciminstance Win32_OperatingSystem | % FreePhysicalMemory
Remotely:
invoke-command computer { get-ciminstance Win32_OperatingSystem | % FreePhysicalMemory }
Free memory of the local machine (use -computername foo
for a remote one):
(Get-WMIObject Win32_OperatingSystem).FreePhysicalMemory # in KB
19793740
(Get-WMIObject Win32_OperatingSystem).FreePhysicalMemory / 1MB # in GB
18.8592491149902
Might seem weird to divide by 1MB to get GB, but the original number is just given in KB. The result is actually no different from writing * 1KB / 1GB
(which you can also use).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.