Thursday, December 26, 2019

PowerShell: Setup your language list, copy settings for new user accounts and the welcome screen

This script will help automate the configuration of language list, as well as copy these settings for new user accounts and the Windows welcome screen.


For our example, we use "en-US" as the preferred language and the secondary "ru-RU":

#Setup User Language List
Set-WinUserLanguageList -Force 'en-US', 'ru-RU'
#Copy User Language List to Welcome screen and New user accounts
$DefaultUserHive = $env:SystemDrive + "\Users\Default\NTUSER.DAT"
reg load HKU\DefaultUserHive $DefaultUserHive
$MyProfileCurrentPath = "Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Keyboard Layout\Preload"
$UserProfiles = Get-ChildItem "Microsoft.PowerShell.Core\Registry::HKEY_USERS"
$MyProfileCurrentPathProperty = (Get-Item $MyProfileCurrentPath).Property
$RegKeyArray = @()
Foreach ($UserProfile in $UserProfiles) {$RegKeyArray += 'Microsoft.PowerShell.Core\Registry::' `
+ $UserProfile.Name  + '\Keyboard Layout\Preload'} 
Foreach ($RegKey in $RegKeyArray) {$MyProfileCurrentPathProperty | ForEach-Object -Process `
{Copy-ItemProperty -Path $MyProfileCurrentPath -Destination $RegKey -Name $_}}
$MyProfileCurrentPath = "Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Control Panel\International\User Profile"
$RegKeyArray = @()
Foreach ($UserProfile in $UserProfiles) {$RegKeyArray += 'Microsoft.PowerShell.Core\Registry::' + $UserProfile.Name `
+ '\Control Panel\International\User Profile'} 
Foreach ($RegKey in $RegKeyArray) {Copy-ItemProperty -Path $MyProfileCurrentPath -Destination $RegKey -Name Languages}
$UserProfile.Flush()
$UserProfile.Close()
$UserProfiles.Flush()
$UserProfiles.Close()
While (!(reg unload HKU\DefaultUserHive)){}

You must run the script with elevated privileges.

No comments:

Post a Comment