标题说明了一切。我有一个工作正常的PS代码,希望将结果输出到文本或excel文件中。
$computers = get-content
"C:\Users\Administrator\Desktop\David\FINAL\RamCheck\input.txt"
Perform an operation for each row in the file
foreach ($strComputer in $computers) {
$colSlots = Get-WmiObject -Class "win32_PhysicalMemoryArray" -namespace
"root\CIMV2" -computerName $strComputer
write-host ""
$colSlots = Get-WmiObject -Class "win32_PhysicalMemoryArray" -namespace
"root\CIMV2" -computerName $strComputer
$colRAM = Get-WmiObject -Class "win32_PhysicalMemory" -namespace
"root\CIMV2" -
computerName $strComputer
$NumSlots = 0
$SlotsFilled = 0
$TotMemPopulated = 0
$colRAM | ForEach {
“Memory Installed: ” + $_.DeviceLocator
“Memory Size: ” + ($_.Capacity / 1GB) + ” GB”
$TotMemPopulated = $TotMemPopulated + ($_.Capacity / 1GB)
if ($_.Capacity = 0)
{write-host "found free slot"}
write-host ""
write-host "=== Summary Memory Slot Info for computer:" $strComputer "==="
write-host "Total Memory Populated = " $TotMemPopulated "GB"
我尝试使用
export-csv -append $fileOutput -Encoding utf8