Z
Z
Z-RoVeR2018-08-07 17:57:31
PowerShell
Z-RoVeR, 2018-08-07 17:57:31

Weird Export-csv output from PowerShell. The reason, as I understand it, is not in the encoding, but in what?

Let's take this small script as an example:

Get-Service -Name "wuauserv" -ComputerName "server1", "server2", "server3" | FT -Property MachineName, Status, Name | Export-Csv -Path C:\tmp\wuausrv_status.csv -Delimiter ";" -Encoding Unicode

Then in the csv file I get this at the output:
5b69b2b78abd1798778987.png
And if I display it in the console without export, then everything is ok:
5b69b2c914e01337695715.png
This is not the only example when I get this at the export-csv output.
I changed the encoding, there was both Unicode and UTF8 and others - the result is the same.
PSVersion: 5.1.14409.1012

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Newerindian, 2018-08-15
@Z-RoVeR

Don't use Format-Table when exporting. This cmdlet changes the display of output in the terminal, but does not change the object in the pipe. Instead, use Select-Object
Get-Service -Name "wuauserv" -ComputerName "server1", "server2", "server3" | Select-Object MachineName, Status, Name | Export-Csv -Path C:\tmp\wuausrv_status.csv -Delimiter ";" -Encoding Unicode -NoTypeInformation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question