Reputation: 89
I am trying to get Windows Display Language setting via powershell on remote computer. I tried Get-WinUserLanguageList but this returns the list of all languages. Get-WinSystemLocale and Get-Culture are also not the ones that i am looking for because Culture returns something for syntax settings and stuff and system local depends to my server. All three are different values for remote desktop. Is there a way to get current display language of remote desktop?
What i am looking for is this setting of remote computer:
Upvotes: 4
Views: 17347
Reputation: 439307
Ash's helpful answer is the best solution for machines running Windows 8 or above / Windows Server 2012 R2 or above.
If you still need to run remotely on a Windows 7 / Windows Server 2012 machine:
(Get-ItemProperty 'HKCU:\Control Panel\Desktop' PreferredUILanguages).PreferredUILanguages[0]
Background information:
In local execution, the simplest solution is to use $PSUICulture
(returns a string with the language name, such as en-US
) or Get-UICulture
(returns a [cultureinfo]
object), as shown in this answer.
However, this doesn't work when you use PowerShell remoting (which is why the above solution / Ash's solution is necessary):
# Does NOT return the target user's display language.
# Seemingly always returns the OS installation language.
Invoke-Command -ComputerName $someComputer { $PSUICulture }
I'm unclear on the exact reasons, but it may be related to the fact that remotely executed PowerShell code runs in an invisible window station that is distinct from the interactive desktop.
Upvotes: 4
Reputation: 3246
The language you see there is the first one in the list from Get-WinUserLanguageList
.
PS C:\> (Get-WinUserLanguageList).LocalizedName
Russian
English (United States)
When I change the order of the list, and set English first, it reverses the order in PowerShell.
PS C:\> Set-WinUserLanguageList -LanguageList en-US,ru
Confirm
Continue with this operation?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y
PS C:\> (Get-WinUserLanguageList).LocalizedName
English (United States)
Russian
So to get the current language, you merely have to call the first object in that list.
(Get-WinUserLanguageList)[0].LocalizedName
Upvotes: 3