Shumii
Shumii

Reputation: 4581

Changing Windows local user regional settings via Powershell

I have created over 100 users using the wrong regional settings, therefore wrong date format. I wish to correct this without logging in as every user and going through the necessary steps.

I am looking for a way to do this in one go either via UI or via Powershell script.

Ideally I want a script that will ForEach the local users and run a command to change their language/regional settings.

NOTE: I am not using Active Directory therefore cannot use group policies.

Upvotes: 1

Views: 7997

Answers (1)

Avshalom
Avshalom

Reputation: 8889

Set your desired settings in one of the users, then Get those settings from

"HKEY_CURRENT_USER\Control Panel\International"

find the SID of each user then

Apply it to each user on:

"HKEY_USERS\[UserSID]\Control Panel\International"

To get The SID of the user you can use this Function:

Function GetSIDfromSAM()
{
    Param(
        [Parameter(mandatory=$true)]$userName
    )
    $myacct = Get-WmiObject Win32_UserAccount -filter "Name='$userName'" 
    return $myacct.sid
}

GetSIDfromSAM localuser
S-1-5-21-1837353773-20556466214-3321741005-1005

Then use the Foreach section (just for example)

New-PSDrive HKU Registry HKEY_USERS

Foreach ($SID in $SIDs)
{
Set-ItemProperty -Path "HKU:\$SID\Control Panel\International" -Name "LocaleName" -Value "en-us"
}

Of course you should update all the properties, you can use a switch section with all properties and values, or other methods, let me know if you need more help on this

Upvotes: 1

Related Questions