Handling international WMI clients / servers with Hyper-V

Handling international WMI clients / servers with Hyper-V

  • Comments 3


If you ever try to run a WMI script / program against Hyper-V on a system that is using a language (or locale) different to your own – you may be surprised to see that a number of the properties are localized.  This can cause problems if you are checking for language specific strings.

Take the following example:

When retrieving a list of virtual machines from Hyper-V it is usual to look at the caption – in order to filter out the MSVM_ComputerSystem entry of the parent partition.  You would do this in PowerShell with a command like this:

gwmi MSVM_ComputerSystem -namespace root\virtualization | where {$_.caption -eq "Virtual Machine"}

But if I run this command on a German installation of Windows:

Capture1

I get no results.  If I remove the where clause you can quickly see the problem:

Capture3

On this system the caption field is not “Virtual Machine” but is “Virtualler Computer”.

So what should you do to handle this?  Well – the answer is quite simple.  In WMI the server will always try to respond in the language that is used by the client.  Normally the client just picks up the language automatically – but you can manually specify a language to be used.  Here is the same PowerSehll command from above – but this time I am requesting that the server always respond in English:

gwmi MSVM_ComputerSystem -namespace root\virtualization -locale MS_409 | where {$_.caption -eq "Virtual Machine"}

Running this yields the expected results:

Capture4

A couple of things to note here:

Cheers,
Ben

Leave a Comment
  • Please add 1 and 1 and type the answer here:
  • Post
  • I'm trying to get my server to respond to that exact command and it is in German, but I am still getting nothing with the -locale MS_409. Any thoughts as to why that might be?

    Thanks

  • William -

    Does it work if you do not use -locale?

    Cheers,

    Ben

  • Hi Ben,

    on my german Windows 7 its always german:

    PS C:\Users\Administrator> gwmi Win32_TimeZone | select StandardName

    StandardName

    ------------

    Mitteleuropäische Zeit

    PS C:\Users\Administrator> gwmi Win32_TimeZone -locale MS_409 | select StandardName

    StandardName

    ------------

    Mitteleuropäische Zeit

    What can I do?

    Cheers

    Enno

Page 1 of 1 (3 items)