Encoding stdout in execute-command node


I have an encoding problem from the stdout of execute-command node.

From the execute-command node I run a powershell command that returns a list of users.
this cmd line :
powershell "Get-ADUser -Filter {(enabled -eq $true) -and (givenName -ne 'null') -and (Surname -ne 'null')} -Properties * | Select SamAccountName, Enabled, GivenName, Surname, UserAccountControl, @{Name='lastLogon';Expression={[datetime]::FromFileTime($_.'lastLogon')}} | ConvertTo-Json"

resulting bad encoding from stdout :

François > Fran�ois

But if i ran this from powershell terminal, is working great.

There any idea to get good stdout ? idon’t know what using, utf8, latin ?


n8n latest
npm 18.12.1

Hey @Jeremy_Bepoix,

I would have thought we would handle that but maybe we are doing some odd conversion step in the node. I know you said you ran it from the powershell terminal and all was good do you still get a good output if you swap to cmd then run the command?

With the cmd prompt working good.

That does look good, I don’t have Windows running at the moment but I will assign this one to Tom to take a quick look at when he returns on Monday.

Hi all, unfortunately I am not a member of an AD domain nor do I have a Windows server running so I can’t test this exact cmdlet myself I am afraid.

However, I can reproduce the problem by running powershell "echo François":

From reading this SO thread it seems this happens outside of n8n as well (n8n itself simply uses child_process.exec here, so no external library).

And indeed, running cmd /c chcp 65001>nul && powershell "echo François" works:

Perhaps you can give this a go @Jeremy_Bepoix and let me know if you’re still having trouble afterwards?

Great ! Thank you

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.