Modify Regional Settings on Windows 10 (Multiple countries), just a simple powershell script!

Hey, I have been working with a script that modifies/changing the Regional settings for the client.
Changing the following:
Format
Timezone
Keyboard layout
Welcome screen-Keyboard layout

Its just one PowerShell script so this work even with Windows 10 Autopilot.
Requirements:
English Operating system (1703 or above)
Client that a could run PowerShell in the customization process (SCCM, Intune or MDT)

So what do you need to figure out something that is unique to every client that can connect to the country? It could be an IP address, computer name, Device variable.
So if you want a Swedish client, we need something that says it should run the Swedish configuration right?
In my test lab, I have every device with a device variable for each country
Like this:

Guidance
  1. Ok now let’s take look at the script.
    Here´s the script
    RegionalSettings
    we go down to the Custom variable part

    ########################################
    ########## CUSTOM VARIABLES ############
    ########################################
    #SWEDEN
    if (($tsenv.Value("Country")) -eq "Sweden")
    {
    $Inputprofile = "sv-SE"
    $InputLanguageID ="041d:0000041d"
    $Geoid = "221"
    $timezone = "W. Europe Standard Time"
    Writelog "Found a match, country is Sweden"
    }
    ############
    

    We need to find the values of each country you can find it here:
    $Inputprofile = https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-input-locales-for-windows-language-packs

    $InputLanguageID = https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-input-locales-for-windows-language-packs

    $Geoid = https://docs.microsoft.com/sv-se/windows/desktop/Intl/table-of-geographical-locations

    $Timezone = https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-time-zones

    Depending on what we have in the value ($tsenv.Value(“Country”) (Which is the device variable) Easy right? 🙂
    If you don’t have any other countries than Sweden, you can just remove the if statement, but I will put a separate script so you can use instead 🙂 (SE-Regionalsettings.ps1)

  2.  Done. Save the script and put in in SCCM/Intune or MDT.
    Explanation

    Gonna explain the script a bit more so you know what’s happening.

    We need to have a path that we can create the .xml file. So the first thing that the script actually does is that it will create a .xml file, “like a template”.

    
    #########################################
    ########## STATIC VARIABLES ###############
    #########################################
    
    WriteLog "Successfully added variables inputprofile=$Inputprofile,inputlanguageid=$InputLanguageID and GeoID=$Geoid"
    $path = "C:\Windows\Temp\Country.xml"
    Writelog "Creating $path"
    New-item $path -ItemType File -Force -ErrorAction SilentlyContinue
    Writelog "Successfully created $path"
    
    #Putting the base info in the xml file
    Writelog "Putting the base info in the xml file"
    Set-content $path '<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">
    <!--User List-->
    <gs:UserList>
    <gs:User UserID="Current" CopySettingsToSystemAcct="true" CopySettingsToDefaultUserAcct="true" />
    </gs:UserList>
    
    <!--Display Language-->
    <gs:MUILanguagePreferences>
    <gs:MUILanguage Value="MUILanguageValue" />
    <gs:MUIFallback Value="en-US" />
    </gs:MUILanguagePreferences>
    
    <!--User Locale-->
    <gs:UserLocale>
    <gs:Locale Name="UserLocaleValue" SetAsCurrent="true" ResetAllSettings="false"/>
    </gs:UserLocale>
    
    <!--input preferences-->
    <gs:InputPreferences>
    
    <!--en-US-->
    <gs:InputLanguageID Action="add" ID="0409:00000409"/>
    
    <!--Specific-Language-->
    <gs:InputLanguageID Action="add" ID="InputLanguageIDValue" Default="true"/>
    
    </gs:InputPreferences>
    
    <!--location-->
    <gs:LocationPreferences>
    <gs:GeoID Value="GeoIDValue"/>
    </gs:LocationPreferences>
    </gs:GlobalizationServices>'
    Writelog "Successfully Putting the base info in the xml file"
    

    Then push information into the .xml file

    #Changing MUILanguageValue,UserLocaleValue,InputlanguageIDValue,GeoIDValue
    Writelog "Changing MUILanguageValue,UserLocaleValue,InputlanguageIDValue,GeoIDValue"
    (get-content $path) | foreach-object {$_ -replace "MUILanguageValue", "$Inputprofile"} | set-content $path
    (get-content $path) | foreach-object {$_ -replace "UserLocaleValue", "$Inputprofile"} | set-content $path
    (get-content $path) | foreach-object {$_ -replace "InputLanguageIDValue", "$InputLanguageID"} | set-content $path
    (get-content $path) | foreach-object {$_ -replace "GeoIDValue", "$GeoID"} | set-content $path
    Writelog "Successfully Changing MUILanguageValue,UserLocaleValue,InputlanguageIDValue,GeoIDValue"
    

    Then it will execute the commando to change the regional settings, and it will use the .xml we just created.

    #Executing the regionsetting values
    Writelog "Executing the regionsetting values"
    Start-Process -FilePath 'control.exe' -ArgumentList ('intl.cpl,,/f:"C:\Windows\Temp\Country.xml')
    Writelog "Successfully the regionsetting values"
    

After that we need to wait one sec, dont know why, but it fails if i we dont wait here 🙂

start-sleep 1

Right after that, we need to push in information to the ntuser.dat, to change the welcome screen, because the login screen doesn’t have any specific user profiles

#Changing the WelcomeScreen to fit the default layout
REG LOAD "HKU\DefaultUserTemplate" "C:\Users\Default\ntuser.dat"
Writelog "Changing to default keyboard layout"
Set-ItemProperty -Path "HKU:\.DEFAULT\Keyboard Layout\Preload" -Name "1" -Type String -Value $GeoID
Set-ItemProperty -Path "HKU:\.DEFAULT\Keyboard Layout\Preload" -Name "2" -Type String -Value 00000409
REG UNLOAD "HKU\DefaultUserTemplate"
Writelog "Successfully Changing to default keyboard layout"

#BlockUserInputMethodsForSignin
Writelog "Changing the BlockUserInputMethodsForSignin"
New-Item -Path "HKLM:\Software\Policies\Microsoft\Control Panel" -ItemType key
New-Item -Path "HKLM:\Software\Policies\Microsoft\Control Panel\International" -ItemType key
New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Control Panel\International" -Name "BlockUserInputMethodsForSignIn" -Type DWORD -Value 1
Writelog "Successfully changing the BlockUserInputMethodsForSignin"

The very last part is changing the timezone.

#Changing Timezone
writelog "Changing Timezone"
tzutil /s "$timezone"
writelog "Successfully changed Timezone"

Done, now we know everything that the script does, hope it made your day 🙂

Happy Easter everyone
/Pontus

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s