簡體   English   中英

Windows 7-使用Powershell腳本獲取RAM詳細信息

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

是否有任何直接/簡單的命令可以通過PS腳本獲取RAM信息,例如4GB。

例如。 檢索操作系統名稱我正在使用此命令:

(Get-WmiObject Win32_OperatingSystem).Caption

您在使用WMI對象的正確路徑上。

快速的答案是:

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

它基於以下答案:

如何通過WMI查詢獲取GB中的總物理內存(RAM)信息?

您應該考慮切換到CIM。

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

在此處閱讀有關CIM與WMI的更多信息:

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM