2

How can I force dnscmd.exe to provide its output in English?

I have automation that parses the output of various dnscmd commands, such as dnscmd /info > dnsInfo.txt. I'm using PowerShell to execute those dnscmd commands, and I have no direct access to these servers (locally executed on my behalf by the server owner). 99% of the MS DNS servers that I encounter, regardless of their home country, are installed using the English edition. However, a handful are installed with a non-English edition, and it appears that dnscmd.exe uses different descriptive text fields when that scenario occurs. This breaks my parsing logic, and I'd love to avoid adding language specific regex each time.

For example, here are the first few words from running dnscmd /info on a non-English (Moroccan French) server:

Résultat de la requête :

Informations sur le serveur
    nom du serveur

Alternatively, is there a way to instruct PowerShell to setup its environment under a different language? That might convince dnscmd.exe to change its output.

Update, This did not work:

function Set-Culture([System.Globalization.CultureInfo] $culture)
{
  [System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture
  [System.Threading.Thread]::CurrentThread.CurrentCulture = $culture
}
Set-Culture "en-US"
dnscmd.exe /info
HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
scottwed
  • 21
  • 3
  • I know you can install the en-US help to force PowerShell to use English, but not sure that would translate into the dnscmd commands. First run `Update-Help -UICulture en-US`. Then run your script as such: `[Threading.Thread]::CurrentThread.CurrentUICulture = 'en-US'; .\dnsscript.ps1` – bentek Sep 30 '14 at 22:33
  • 1
    I've been able to reproduce this behavior by installing a Spanish MUI pack on a Windows 2008 R2 SP1 server, and then changing the display language to Espanol. – scottwed Oct 01 '14 at 02:06
  • `dnscmd.exe` is a a native Windows application, though. I don't think Powershell or .NET related options will affect it. – Håkan Lindqvist Oct 21 '14 at 19:02
  • 1
    Try running "chcp 437" before the "dnscmd.exe /info" command. – Signal15 Nov 21 '14 at 14:24

0 Answers0