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.

cometfish
  • 103
  • 1
  • 1
  • 5
  • 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 06 '17 at 21:23
  • Yes, makes sense re: current user settings. That's why I tried the region xml file to apply those settings to the Default user, but no luck. Interested to see what you can find for the systemlocale. – cometfish Jan 07 '17 at 00:59
  • I was able to run Set-WinSystemLocale in a startup script with 'windows-startup-script-ps1' and it worked after a reboot on a server 2016 and 2012 instance, it appears like it can't be set during sysprep specialize. – Faizan Jan 25 '17 at 15:32
  • Thanks, yes looks like that one works, after reboot. Were you able to get the Culture setting changed though? I think it's this one that sets the date/time format settings. I'm running .NET code on the machines - don't want the difference in date format between AU and US to mess anything up. (I've forced .NET to use AU date format in my code, but it would be good to cover all bases.) – cometfish Jan 31 '17 at 21:52
  • The Set-Culture change the settings for current user. This will not work with the startup script. – Faizan Feb 15 '17 at 00:31

1 Answers1

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.

Faizan
  • 1,438
  • 10
  • 18