How to use Powershell to configure "Region and Language" settings in win7 or win2008

I'm new to Powershell and I've been searching the web all day, but still can't figure out how to configure Region and Language settings using Powershell in win7 or win2008.

I want to change the following parameters in Powershell:

  1. Current system language

  2. Short date and long date format

  3. Short and long time format

  4. Current location

Does anyone know how to do this using Powershell? Cmd / Bat / .NET solutions are also welcome!

+4


source to share


3 answers


I know your question was about Windows 7; this information may be helpful for those working with newer versions. , and in Windows 8 and above , allow you to manage the installed languages. For example, to add a language: Set-WinUserLanguageList

New-WinUserLanguageList

Get-WinUserLanguageList

Get-WinUserLanguageList

$list = Get-WinUserLanguageList
$list.Add("fr-FR")
Set-WinUserLanguageList $list

      

Set-Culture

in PowerShell 3 allows you to change the culture, for example, choose the default values ​​for Germany:

Set-Culture de-DE

      

Or, to set custom formats:



$culture = Get-Culture
$culture.DateTimeFormat.ShortDatePattern = 'yyyy-MM-dd'
$culture.DateTimeFormat.LongDatePattern = 'dddd, d MMMM yyyy'
$culture.DateTimeFormat.ShortTimePattern = 'h:mm tt'
$culture.DateTimeFormat.LongTimePattern = 'h:mm:ss tt'
Set-Culture $culture

      

To change the location, use , for example, to set the user's location in Austria: Set-WinHomeLocation

Set-WinHomeLocation -GeoId 14

      

MSDN has a list of GeoIds, and TechNet has a reference for international settings cmdlets .

+6


source


@bourne led me to

& $env:SystemRoot\System32\control.exe "intl.cpl,,/f:`"c:\setKeyboardUK.xml`""

      

Note that there is no space between, and / f, the use of quotes around the entire object, and a backtick to avoid quotes along the way (which are necessary).

This is my setKeyboardUK.xml file



<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend"> 
<!--User List-->
<gs:UserList>
    <gs:User UserID="Current" CopySettingsToDefaultUserAcct="true" CopySettingsToSystemAcct="true"/> 
</gs:UserList>
<gs:UserLocale> 
    <gs:Locale Name="en-GB" SetAsCurrent="true"/> 
</gs:UserLocale>
<!--location--> 
<gs:LocationPreferences> 
    <gs:GeoID Value="242"/> 
</gs:LocationPreferences>
<gs:InputPreferences>
    <!--en-GB--> 
    <gs:InputLanguageID Action="add" ID="0809:00000809" Default="true"/> 
</gs:InputPreferences>

      

To check if the settings are applied (since errors are inactive) open "Event Viewer" and "Application and Service Logs" then "Microsoft", "International", "Operational" any successful changes or failures are logged here (logging by default) ...

FYI I did it all on Powershell 3 on Windows 2008 R2 64bit. YMMV

+3


source


Hey, I know this is a long time ago, but I had to do the same, but I did it in a script package. I am currently trying to figure out how to do this in powershell.

Check out my post here https://superuser.com/questions/353752/windows-7-change-region-and-language-settings-using-a-script

The same should be applied in Powershell using the following command:

PS C:\> & $env:SystemRoot\System32\control.exe "intl.cpl,, /f:path\to\xml\file\change_system_region_to_US.xml"

      

However for me this somehow doesn't work, although the command is executed without error, the changes don't actually take effect.

If you run the same command from the standard CMD window, the changes will take effect immediately. And if you remove the quotes to match how you ran it in the CMD window, you get the following error:

PS C:\> & $env:SystemRoot\System32\control.exe intl.cpl,, /f:"path\to\xml\file\change_system_region_to_US.xml"
    Missing argument in parameter list.
    At line:1 char:50
    + & $env:SystemRoot\System32\control.exe intl.cpl,, <<<<  /f:"path\to\xml\file\change_system_region_to_US.xml"
        + CategoryInfo          : InvalidOperation: (,:String) [], RuntimeException
        + FullyQualifiedErrorId : MissingArgument

      

Powershell doesn't seem to be much like a comma.

Doing this in a .bat file works like a charm though. Just make sure you get your country codes and everything is correct. It may take a little processing of the .xml file to change the required parameters.

+1


source







All Articles