【发布时间】:2017-03-29 10:33:04
【问题描述】:
我需要清点文本文件中列出的计算机的 RAM。我有这个脚本:
$($servers = Get-Content D:\123.txt
Foreach ($s in $servers) {
$s
get-wmiobject Win32_Processor -ComputerName $s -ErrorAction SilentlyContinue| select Name | Format-List
Get-WmiObject win32_baseboard -ComputerName $s -ErrorAction SilentlyContinue| Select product | Format-List
$colRAM = Get-WmiObject -Class "win32_PhysicalMemory" -namespace "root\CIMV2" -computerName $s
$colRAM | ForEach {
“Memory Installed: ” + $_.DeviceLocator
“Memory Size: ” + ($_.Capacity / 1GB) + ” GB”
$SlotsFilled = $SlotsFilled + 1
$TotMemPopulated = $TotMemPopulated + ($_.Capacity / 1GB)
}
Write-Host "_____________________________________ "
}) *>&1 > output.txt
返回这个结果:
电脑1
名称:Intel(R) Core(TM)2 Duo CPU E8500 @ 3.16GHz
产品:DG31PR
安装的内存:J6H2 内存大小:1 GB
我希望结果是这样并导出为 CSV:
Name TotalRam Type Motherboard
comp1 2gb ddr3 h81m-k
comp2 2gb ddr3 h81m-k
2gb
comp3 1gb ddr2 DG31PR
0,5gb
【问题讨论】:
标签: powershell csv ram