简体   繁体   English

Windows 7-使用Powershell脚本获取RAM详细信息

[英]Windows 7 - Get RAM details using powershell script

Is there any direct/simple command to get the RAM information through PS script, for example 4GB. 是否有任何直接/简单的命令可以通过PS脚本获取RAM信息,例如4GB。

For eg. 例如。 to retrieve OS Name I am using this command: 检索操作系统名称我正在使用此命令:

(Get-WmiObject Win32_OperatingSystem).Caption

You are on the right path, using the WMI objects. 您在使用WMI对象的正确路径上。

The quick answer is: 快速的答案是:

(Get-WmiObject Win32_ComputerSystem).totalphysicalmemory / (1024 * 1024 * 1024)

It is based on this answer: 它基于以下答案:

How to get total physical memory (ram) information in GB by WMI query? 如何通过WMI查询获取GB中的总物理内存(RAM)信息?

You should consider switching to CIM. 您应该考虑切换到CIM。

(Get-CimInstance -ClassName Win32_ComputerSystem).totalphysicalmemory / (1024 * 1024 * 1024)

Read more about CIM vs. WMI here: 在此处阅读有关CIM与WMI的更多信息:

https://blogs.technet.microsoft.com/heyscriptingguy/2016/02/08/should-i-use-cim-or-wmi-with-windows-powershell/ https://blogs.technet.microsoft.com/heyscriptingguy/2016/02/08/should-i-use-cim-or-wmi-with-windows-powershell/

微软曾表示CIM是未来。

((Get-CimInstance CIM_PhysicalMemory).Capacity | Measure-Object -Sum).Sum / (1024 * 1024 * 1024)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Azure 中,使用 powershell 脚本在 csv 文件中获取负载均衡器详细信息 - In Azure, To get Load balancer details in to csv file using powershell script 通过 PowerShell 获取已卸载 Windows fonts 的详细信息 - Get details of uninstalled Windows fonts via PowerShell Powershell脚本获取IIS配置详细信息 - Powershell script to get IIS configuration details 如何使用占用所有 RAM 的 Get-ChildItem 优化 Powershell 脚本 - How to optimize Powershell script with Get-ChildItem consuming all RAM 如何使用Powershell或任何Windows脚本获取文件夹名称? - How to get folder names using powershell or any windows script? 如何使用Powershell在Windows Server中以csv格式获取磁盘详细信息 - How can i get the disk details in csv format in windows server using powershell 如何使用 PowerShell 获取多台计算机的 RAM/内存详细信息? - How can I use PowerShell to get RAM / Memory details of multiple computers? 如何使用Powershell从注册表获取详细信息? - How to get details from Registry using Powershell? 用于获取用户及其所属组的详细信息的 Powershell 脚本 - Powershell Script to get details of user along with group they are member of 如何使用通过 a.Net PowerShell object 运行的 PowerShell 脚本获取 windows 注册表属性值? - How do I get windows registry property values using a PowerShell script run through a .Net PowerShell object?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM