【问题标题】:How can i filter out information in powershell?如何过滤掉powershell中的信息?
【发布时间】:2020-04-22 12:22:51
【问题描述】:

如何过滤掉powershell中的信息?

例如,我在远程机器上运行系统信息, 我会写:

systeminfo -s <computerName>

但是,我怎样才能对许多机器执行此操作,以及如何过滤掉信息?

我想在很多机器上搜索“总物理内存”

【问题讨论】:

  • 而不是使用那个... icky util,为什么不使用powershell CIM cmdlet 来获取信息? [grin] ///// 我很困惑……你只想要 RAM……还是想要除了 RAM 之外的所有东西?

标签: windows powershell cmd remote-access remote-desktop


【解决方案1】:

正如@Lee_Daily 所建议的,使用 Powershell 会更容易、更直接。

这将产生以 GiB 为单位的物理内存量。

(Get-CimInstance -ClassName CIM_PhysicalMemory | Measure-Object -Sum Capacity).Sum / 1GB

【讨论】:

    【解决方案2】:

    Windows 10 64 位。 PowerShell 5。

    如何使用 PowerShell 为一台计算机查找“总物理内存”。替换computername

    systeminfo -s computername | Select-String 'Total Physical Memory:').ToString().Split(':')[1].Trim()
    

    我无法测试:

    如何在多台计算机上使用 PowerShell 函数查找“总物理内存”。

    Get-SystemInfo -ComputerName server01,server02 
    

    您可以通过gallery.technet.microsoft.com 获得get-systeminfo

    【讨论】:

    • 什么是Get-SytemInfo[原文如此]?是this吗?请在参考。还是你的意思是Get-ComputerInfo
    • @chr 谢谢。
    猜你喜欢
    • 1970-01-01
    • 2012-07-19
    • 2018-08-29
    • 1970-01-01
    • 2018-02-20
    • 2022-06-19
    • 1970-01-01
    • 1970-01-01
    • 2013-09-22
    相关资源
    最近更新 更多