Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Convert XML to CSV with utf8 encoding in Powershell 3.0 (Windows Server 2012)?

$
0
0

Hi all

I've looked through loads of threads, but haven't been able to find a solution, so I hope you can help me.

I use this script to convert in Powershell 2 and have been trying all day to get it working fully in Powershell 3. Can anyone tell me how it would look and work in Powershell 3?

#Read from file

[xml]$inputFile Get-Content ".\File.xml"

#Export XML as CSV

$inputFile.users_xml.Childnodes | Export-Csv ".\File.csv" -NoTypeInformation -Delimiter:";" -Encoding:UTF8

This works flawlessly in Powershell 2, but in Powershell 3 i can see that it apparently doesn't take into account the UTF8 encoding as special characters such as æ ø å ö ä and so on all look wrong.

If I use the built-in command builder in ISE I end up with something like this:

Export-Csv-InputObject$inputFile.users_xml.ChildNodes-Delimiter";"-EncodingUTF8-NoTypeInformation-Path.\File.csv

However the csv file just contains something like:

"Count"
"789"

What am I doing wrong? Thanks!



Viewing all articles
Browse latest Browse all 15028

Trending Articles