当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] PowerShell:检索和存储域计算机的硬件信息

作者:精品下载站 日期:2024-12-14 07:27:38 浏览:15 分类:玩电脑

PowerShell:检索和存储域计算机的硬件信息


WMI 是一个强大的功能。在本文中,我将检索所有域计算机的已安装内存 (RAM) 信息并将输出存储在文件中。

防火墙

为了运行查询,必须在所有域计算机上启用 WMI 入站防火墙规则。这可以手动或使用组策略来完成。

[玩转系统] PowerShell:检索和存储域计算机的硬件信息

在所有域计算机上运行 WMI 查询

然后运行 Get-WmiObject。

Get-WMIObject -ComputerName (Get-ADComputer -Filter *).Name -Class Win32_Computersystem -ErrorAction SilentlyContinue | Select-Object @{n="Computer"; e={$_.PSComputerName}}, @{n="RAM/GB"; e={[Math]::Round($_.TotalPhysicalMemory/ 1GB)}}

[玩转系统] PowerShell:检索和存储域计算机的硬件信息

为了使其更加用户友好,将其通过管道传输到 Out-GridView。

 Get-WMIObject -ComputerName (Get-ADComputer -Filter *).Name -Class Win32_Computersystem -ErrorAction SilentlyContinue | Select-Object @{n="Computer"; e={$_.PSComputerName}}, @{n="RAM/GB"; e={[Math]::Round($_.TotalPhysicalMemory/ 1GB)}} | Out-GridView 

仅在服务器上运行

仅对服务器执行查询可能更有用。这些通常始终处于开启状态。

Get-WMIObject -ComputerName (Get-ADComputer -Filter 'operatingsystem -like "*server*"').Name -Class Win32_Computersystem -ErrorAction SilentlyContinue | Select-Object @{n="Computer"; e={$_.PSComputerName}}, @{n="RAM/GB"; e={[Math]::Round($_.TotalPhysicalMemory/ 1GB)}} | Out-GridView

或者将其另存为 HTML 文件。

Get-WMIObject -ComputerName (Get-ADComputer -Filter 'operatingsystem -like "*server*"').Name -Class Win32_Computersystem -ErrorAction SilentlyContinue | Select-Object @{n="Computer"; e={$_.PSComputerName}}, @{n="RAM/GB"; e={[Math]::Round($_.TotalPhysicalMemory/ 1GB)}} | ConvertTo-Html -Title "RAM all Servers" | Set-Content C:\temp\RAM.htm

[玩转系统] PowerShell:检索和存储域计算机的硬件信息

结论

WMI 查询只能从已打开电源的计算机中检索信息。 SCCM 使用客户端代理,在预先配置的时间周期内向管理服务器报告硬件和软件库存。有关 SCCM 的更多信息,请访问:https://www.microsoft.com/en-us/cloud-platform/system-center-configuration-manager

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯