Power Shell Output Help

david_621

Commendable
Feb 24, 2017
11
0
1,510
So im not sure if this is the right area to post in but i need help with a power shell script.

it runs fine i just cant get it to output to a text file.

ive tried Write-Host then file-out, export-csv, making an arry then trying to output that.
but no luck with anything.

Any help with getting the output on console into a text file would be appreciated.



Code:
# Read all the computers from the file
$computers = get-content "C:\Users\Administrator\Desktop\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

$TotMemPopulated = 0

$colRAM | ForEach {
      
       $TotMemPopulated = $TotMemPopulated + ($_.Capacity / 1GB)

}

write-host ""
write-host "Computer:" $strComputer "=" $TotMemPopulated "GB"
}