windows - 在远程桌面上使用 Powershell 获取 Windows DisplayLanguage

标签 windows powershell

我正在尝试通过远程计算机 上的 powershell 获取 Windows 显示语言设置。我试过 Get-WinUserLanguageList 但这会返回所有语言的列表。 Get-WinSystemLocale 和 Get-Culture 也不是我正在寻找的那些,因为 Culture 返回一些语法设置和东西,系统本地取决于我的服务器。这三个都是远程桌面的不同值。有没有办法获取远程桌面当前的显示语言?

我要找的是远程计算机的这个设置:

enter image description here

最佳答案

Ash's helpful answer适用于运行 Windows 8 或更高版本/Windows Server 2012 R2 或更高版本的机器的最佳解决方案


如果您仍然需要在 Windows 7/Windows Server 2012 机器上远程运行:

(Get-ItemProperty 'HKCU:\Control Panel\Desktop' PreferredUILanguages).PreferredUILanguages[0]

背景信息:

本地执行中,最简单的解决方案是使用$PSUICulture(返回带有语言名称的字符串,例如en-US ) 或 Get-UICulture(返回一个 [cultureinfo] 对象),如 this answer 所示.

但是,当您使用 PowerShell remoting 时,这不起作用(这就是为什么需要上述解决方案/Ash 的解决方案):

# Does NOT return the target user's display language.
# Seemingly always returns the OS installation language.
Invoke-Command -ComputerName $someComputer { $PSUICulture }

我不清楚具体原因,但这可能与远程执行的 PowerShell 代码在与交互式桌面不同的不可见窗口站中运行这一事实有关。

关于windows - 在远程桌面上使用 Powershell 获取 Windows DisplayLanguage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61681766/

相关文章:

c - 在CLI环境下访问本地应用程序文件?

windows - 如何将项目添加到右键单击文件夹菜单?

windows - 在外部应用程序文本区域中设置插入符位置?

wpf - ADFS vNext 客户端身份验证 (WPF) (Windows Server 2016 Preview 3)

powershell - 从目录导入 PowerShell 脚本或模块

c# - 对象引用未设置到对象的实例(验证

windows - MessageBeep 不播放任何声音

powershell - 如何使用 powershell 启动 teams.exe

c# - 通过命令行创建 7-Zip 存档时创建逻辑文件夹结构

powershell - 更改工作流的 SerializationMethod