powershelldbatools

What are the options for the -Encoding parameter in the Import-DbaCsv tool?


I can't figure out what the Import-DbaCsv tool is expecting for the -Encoding parameter.

The docs aren't helpful - https://docs.dbatools.io/#Import-DbaCsv

I've tried UTF-8, UTF8, and UTF in upper case, lower case, with quotes, and without quotes.

I always get and error message like this:

Cannot convert the "UTF-8" value of type "System.String" to type "System.Text.Encoding"


Solution

  • The link you gave us shows the -Encoding parameter is of type <Encoding>, which leads me to believe you need to use any of the [System.Text.Encoding] encoding classes instead of a string:

    enter image description here

    So in your case, use [System.Text.Encoding]::UTF8