我無法理解爲什麼我的csv導出只返回數字而不是我想要的字符串。當我使用out-file而不是export-csv時,一切看起來都不錯。Powershell export-csv返回號碼
$get_child_csv = Get-ChildItem $c_path -ErrorVariable +errors | ?{ $_.PSIsContainer } | select fullname | foreach {$_.fullname} | Export-Csv ".\childitems\csv\$item.csv" -NoTypeInformation -Encoding unicode
$get_child_txt = Get-ChildItem $c_path -ErrorVariable +errors_txt | ?{ $_.PSIsContainer } | select fullname | foreach { $_.fullname } | Out-File ".\childitems\txt\$item.txt"
CSV輸出示例:
Length
41
41
41
41
TXT輸出:
\\SERVER\FILESHARE\FOLDER
\\SERVER\FILESHARE\FOLDER
\\SERVER\FILESHARE\FOLDER
\\SERVER\FILESHARE\FOLDER
我到底做錯了什麼?
刪除'foreach {$ _。fullname}'。 – PetSerAl
如果我這樣做,輸出將不會與txt文件相同。表格標題將顯示在頂部。 – David
[PowerShell - 導出到CSV文件時出錯]的可能副本(http://stackoverflow.com/questions/34796291/powershell-trouble-exporting-to-csv-file) –