This is a two part question about the limits of Out-File and turning string values into objects to use Export-CSV.
I am working on a script to pull various information and add it to an existing csv doc. I am currently using Out-File but I do no think it has the desired functionality.
$date, $computerName, $env:UserName, 'error' | Out-File $report -Append
The above adds all the data in a single column, for instance:
date
computername
username
error
I would like it to read:
date computername username error
I have tried using Export-CSV, but since my variables are strings it just writes the string length instead of the variable. I am happy to use Export-CSV with -Append so long as it reports the items correctly.
Bonus points if we can get the table to have headers like:
date computername username error
8/15/2018 A1 Bob PowerIssue
8/15/2018 A2 Tom InternetIssue