0

I'm trying to set the default locale/region for all users on a Google Compute Engine Windows instance using automated PowerShell startup scripts.

I have tried the following script:

Import-Module International

#set home location to Australia
Set-WinHomeLocation -GeoId 12

# Set locale to English (Australia) (needs a restart)
Set-WinSystemLocale en-AU

# Set regional format (date/time etc.) to English (Australia) - this applies to all users
Set-Culture en-AU

# Set the language list for the user, forcing English (Australia) to be the only language
Set-WinUserLanguageList en-AU -Force

and also this script, using a region xml file to copy the same settings as above to the Default account and System account:

& "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin\gsutil" cp gs://mybucket/auregion.xml C:\
& $env:SystemRoot\System32\control.exe "intl.cpl,,/f:`"c:\auregion.xml`""

Contents of auregion.xml:

<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-AU" SetAsCurrent="true"/> 
   </gs:UserLocale>
   <gs:SystemLocale Name="en-AU"/>
   <!--location--> 
   <gs:LocationPreferences> 
       <gs:GeoID Value="12"/> 
   </gs:LocationPreferences>
</gs:GlobalizationServices>

But neither work when set as windows-startup-script-ps1 or as a sysprep-specialize-script-ps1 in GCE. I know the scripts are running, as it also sets the timezone via tzutil which is working, and it does create the auregion.xml file for the second script.

The same scripts work when run by a user remoting into the VM.

Maybe there is an easier way?? I couldn't see any configuration options in GCE to set locale settings automatically, other than creating a custom image.

9
  • If you were able to solve this, you can post the answer here for other community members who may be seeing this same issue. Changing the default locale/region on your VM and creating an image from the disk for future deployments seems to be a good solution. – Faizan Dec 19 '16 at 20:50
  • 1
    I wasn't able to solve it. – cometfish Dec 19 '16 at 21:56
  • (oops pressed enter for a newline and didn't realise it would post) So my VMs are in the right timezone, but wrong locale. Thought about creating a custom image, but then the image would have to be manually kept up to date with windows updates, which is not ideal. – cometfish Dec 19 '16 at 21:59
  • I'll try to reproduce the issue and investigate it further. I'll get back to you if I find useful information to share. – Faizan Dec 23 '16 at 21:03
  • The parameters Set-WinHomeLocation, Set-Culture and Set-WinUserLanguageList all change settings for the current user, so they will not work via a startup script. I'm still working on finding the reason why Set-WinSystemLocale cannot be set through powershell. Microsoft's documentation on changing language settings for all users only shows how to do it via the UI (all under 'Control Panel\Clock, Language, and Region'), to do it via powershell I believe would require dowloading the pack, setting the correct settings, and some Default User registry editing. – Faizan Jan 6 '17 at 21:23
1

Posting an answer for user's looking at this thread.

Set-WinSystemLocale will work with startup script on GCE using 'windows-startup-script-ps1' key. This requires a reboot as it appears that it can't be set during sysprep specialize.

For Set-WinHomeLocation, Set-Culture and Set-WinUserLanguageList its not possible to set the values using startup script on GCE, as it require all change settings for the current user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.