2

I'm creating Windows server 2016 images in Azure using Packer.

The only thing i'm unable to change is the locale, language and home location in the image. I'm in the UK and everything defaults to US.

I've tried the following Powershell (which works) but only changes the settings for the packer user. When I create a VM from the image and log in it's reverted back to US.

Set-WinHomeLocation -GeoId 0xf2

Set-TimeZone -Name "GMT Standard Time"

Set-WinSystemLocale en-GB

Set-Culture en-GB

Set-WinUserLanguageList -LanguageList (New-WinUserLanguageList -Language en-GB) -Force

Is there a way to change these settings for all users so it's baked into the image?

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
darren25
  • 275
  • 1
  • 5
  • 16

1 Answers1

1

You have a couple options when building an image. If you are not sysprepping at the end, then I would encourage you to do that.

As far as the two options. You can either use the unattend.xml to set these settings or you can add the PowerShell commands to the SetupComplete scripts and it will run these based on the new user that was just created from the image.

Use the SetupComplete.cmd or Unattend.xml file process - This is built into Windows so nothing special needs to occur. You will basically create your own custom SetupComplete script that has the logic that you need to execute to install y our applications and reconfigure your windows server to run as the new user that is created when the image is used to create a new VM. Note that in Azure, Microsfot is using the SetupComplete, so you should call yours SetupComplete2.cmd. I have used this technique to to run custom PowerShell scripts. So the SetupComplete2.cmd will call the PowerShell script. You can have as many of these as you like, just name them with a number in sequence that you want these two run. The scripts will need to be placed in the C:\Windows\OEM folder.

Jamie
  • 3,094
  • 1
  • 18
  • 28
  • I wouldn't call it `SetupComplete2.cmd` either. I use the `Windows 10 Multi Session + O365` image on Azure which already contains a `SetupComplete2.cmd` in `C:\Windows\OEM` **edit**: or is it the intention to *override* that file? – Michael Schnerring May 28 '21 at 12:27