When I run the following code with write-output $obj at the end It prints all of the computers on the screen but when I try to export to csv I only get (one computer) the last computer information in the csv file.
$Computers = get-content C:\POSH\test.txt
foreach ($comp in $Computers) {
$CS = Get-WmiObject -Class Win32_computersystem -ComputerName $comp
$Encl = Get-WmiObject -Class Win32_Systemenclosure -ComputerName $comp
$props = @{CompName=$cs.name
Manufacturer=$cs.manufacturer
Model=$cs.model
Serial=$encl.serialnumber}
$obj = New-Object -TypeName PSObject -property $props
Write-Output $obj
# $obj | export-csv c:\posh\test.csv -Notype (I only get one computer when I replace write-output with this)
}