【问题标题】:Get-WMIObject Speed Property Error (PowerShell)获取 WMIObject 速度属性错误 (PowerShell)
【发布时间】:2016-06-22 13:53:04
【问题描述】:

我正在编写一个脚本来提取 RAM 信息。它当前导出 Max Ram Accepted、Ram Slots、Ram Sticks installed、Total RAM installed、计算机名称和登录用户。

我正在尝试将速度属性添加到输出文件,但由于某种原因,这不是导出。这就是我的命令:

$Speed = get-WMIobject -class win32_PhysicalMemory | measure-object -property speed -sum

对于out-file。我有:

"Ram Speed:" -f $($speed.Sum) | Out-File "$ExportPath\$computerName-Memory_Scan.txt

当我在控制台上运行命令时,它可以正常写入屏幕,但是当我尝试导出到文本文件时,我得到的只是“Ram Speed:”并且没有数据。我错过了什么?

【问题讨论】:

    标签: windows powershell ram get-wmiobject


    【解决方案1】:

    您缺少格式项{0}

    "Ram Speed: {0}" -f $($speed.Sum) | Out-File "$ExportPath\$computerName-Memory_Scan.txt
    

    【讨论】:

    • 就是这样!知道它必须是我需要的疯狂简单的东西。谢谢楼主!
    猜你喜欢
    • 2021-10-30
    • 2019-06-15
    • 1970-01-01
    • 2022-07-02
    • 1970-01-01
    • 2022-12-14
    • 1970-01-01
    • 2013-09-14
    • 2014-07-03
    相关资源
    最近更新 更多