Converting VBScript's GetLocale Function

Windows PowerShell

Definition: Returns the current locale ID value.


InVBScript you can identify the user's locale (which determines such things as keyboard layout and alphabetic sort order, as well as date, time, number, and currency formats) by calling the GetLocale function and then translating the returned ID number. You can get this same locale ID in Windows PowerShell by using the Get-Culture Cmdlet and looking at the value of the LCID property:

$a = (get-culture).lcid

When you run this command and then echo back the value of $a you should get the following, provided your computer has US English configured for its language and regional settings:


If you’d prefer to see the locale name (as opposed to the ID number) use this command instead:

$a = (get-culture).displayname

That will return information similar to this:

English (United States)

Return to the VBScript to Windows PowerShell home page