【发布时间】:2020-05-19 16:13:12
【问题描述】:
我希望得到一些帮助,让我称之为简单的脚本工作,但我已经达到了我的 PS 知识上限。我发现了一些帖子,其他人试图做类似的事情,但对我没有帮助。
我有一个概念,它将数据输出到每台计算机的 CSV 文件中,但每台计算机的信息是相同的。我已经多次修改脚本,但我现在没有想法。我正在运行 PS 5.0。这是我目前所拥有的:
$Computers = get-content "C:\Users\test\documents\computers.txt"
$ExportLocation = "C:\Users\test\documents"
$Score = Get-CimInstance Win32_ReliabilityStabilityMetrics | measure SystemStabilityIndex -Average | select-object -ExpandProperty Average
$Manufacturer = Get-ComputerInfo | select -ExpandProperty "CsManufacturer"
$Output = foreach ($Computer in $Computers) {
New-Object -TypeName PSObject -Property @{
ComputerName = $Computer
StabilityScore = $Score
Manufacturer = $Manufacturer
} | Select-Object ComputerName,StabilityScore,Manufacturer
}
$Output | Export-CSV $ExportLocation\StabilityResults.csv -Append -Force -Encoding ASCII -NoTypeInformation
任何帮助将不胜感激!
【问题讨论】:
标签: powershell powershell-2.0 powershell-3.0 powershell-4.0