I am really confused on why I am getting a funny output when appending string value to a CSV.
I have the following code
Set-Content $AutomonitorCSV -Force -Value "Type,Base,Status"
$now = get-date -Format "ddd MMM dd HH:mm:ss BST yyyy"
$status = "<!>Status,Last ran at $now"
$status >> $AutomonitorCSV
Which outputs
Type,Base,Status
< ! > S t a t u s , L a s t r a n a t M o n J u n 2 0 1 6 : 2 8 : 3 3 B S T 2 0 1 6
I need to append the $status at the end of the csv as the software needs to pick this line up. However it keeps adding spaces after each character. When I output in powershell it looks fine. How do I get it to output properly so I get
Type,Base,Status
<!>Status,Last ran at Mon Jun 20 16:28:33 BST 2016
Note, I have to use PowerShell v2.0 because of 2003 hosts.