1
我真的很困惑,爲什麼我會在將字符串值附加到CSV時得到一個有趣的輸出。CSV追加正常字符串/文本行
我有以下代碼
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
,輸出
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
我需要在CSV的結束$status
追加的軟件需求回暖這條線了。但是它會在每個字符後面添加空格。當我在PowerShell中輸出它看起來很好。我如何得到它的正確輸出,所以我得到
Type,Base,Status
<!>Status,Last ran at Mon Jun 20 16:28:33 BST 2016
注意,我使用的,因爲2003和的主機的PowerShell 2.0。
謝謝,這兩個選項的工作。我確實嘗試了文件,但沒有包含'-Encoding ascii'。 –