How to make wevtutil tool return results in UTF-8 format?

0

I'm writing a script that requires me to look up a specific event in the Windows Event Log using wevtutil tool. The command line goes as such:

wevtutil qe System /q:"*[System[Provider[@Name='Microsoft-Windows-Power-Troubleshooter']]]" /rd:true /c:1 /f:text

but its output is truncated to ANSI encoding and I may lose some non-English characters.

Having looked through its documentation, I found that there's /l: parameter that allows to specify a locale. So I tried this:

wevtutil qe System /q:"*[System[Provider[@Name='Microsoft-Windows-Power-Troubleshooter']]]" /rd:true /c:1 /f:text /l:utf-8

but it gives me:

LCID utf-8 cannot be found. The parameter is incorrect.

Any idea what am I doing wrong?

c00000fd

Posted 2015-12-24T08:47:48.923

Reputation: 339

Answers

1

UTF-8 is not a locale, but a form of character encoding. For valid locales, see this link

From your link, it looks like you simply need /uni:true

Jonno

Posted 2015-12-24T08:47:48.923

Reputation: 18 756

Thank you. I managed to miss it. Although that parameter doesn't use UTF-8. It's more like UTF-16 – c00000fd – 2015-12-24T09:14:02.137

That shouldn't be a problem, it should allow all the characters you need, although may take up a bit more more space in doing so. You could always convert back from UTF-16 to UTF-8 afterwards if you are certain you're not using any characters from UTF-16. – Jonno – 2015-12-24T09:18:45.803