gpt4 book ai didi

windows - 获取 WMIObject 速度属性错误 (PowerShell)

转载 作者:可可西里 更新时间:2023-11-01 11:48:20 26 4
gpt4 key购买 nike

我正在编写一个脚本来提取 RAM 信息。它当前导出接受的最大 Ram、Ram 插槽、安装的 Ram 棒、安装的总 RAM、计算机名称和登录用户。

我正在尝试将 speed 属性添加到输出文件中,但出于某种原因,这没有导出。这是我的命令:

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

输出文件。我有:

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

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

最佳答案

您缺少格式项 {0}:

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

关于windows - 获取 WMIObject 速度属性错误 (PowerShell),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37970152/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com