Powershell 远程会话,似乎无法设置屏幕分辨率?

问题描述 投票:0回答:2

一段时间以来,我一直在尝试通过 Powershell 远程会话设置远程计算机的屏幕分辨率。我可以从 Get-DisplayResolution cmdlet 获取分辨率,然后返回以下信息。

PS C:\> Enter-PSSession -Session $rs
[vm.company.com]: PS C:\Users\username\Documents> cd \
[vm.company.com]: PS C:\> Get-DisplayResolution
1024x768

[vm.company.com]: PS C:\> Set-DisplayResolution -Width 1440 -Height 900 -Force
setres will now attempt to apply the following display settings:   

  Width:          1440                       
  Height:         900

The settings passed in could not be applied to the graphics device.

[vm.company.com]: PS C:\> Set-DisplayResolution -Width 1024 -Height 768 -Force
setres will now attempt to apply the following display settings:

  Width:          1024
  Height:         768

The settings passed in could not be applied to the graphics device.

[vm.company.com]: PS C:\>

这非常令人沮丧,因为我什至似乎无法将显示分辨率更改为当前设置的分辨率,因为我一直收到错误消息

传入的设置无法应用于图形设备 .

我已经在我的本地机器上试过了,它似乎工作得很好。这是显示在远程计算机上的 Powershell 版本。

[vm.company.com]: PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      3.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.34209
BuildVersion                   6.2.9200.17065
PSCompatibleVersions           {1.0, 2.0, 3.0}
PSRemotingProtocolVersion      2.2


[vm.company.com]: PS C:\>

有人知道解决这个问题的方法吗?提前谢谢你。

powershell screen-resolution powershell-remoting powershell-cmdlet
2个回答
1
投票

虽然这不是问题的直接答案,但最终它也不像我希望的那样可靠和干净。我找到了一个解决方法,可以让我在可以从我们的 CI 服务器启动的远程机器上执行端到端测试。 [自动化您的远程桌面会话]https://outofmemoryexception.wordpress.com/2016/03/29/automate-your-remote-desktop-sessions/。希望您会发现它在您的场景中也很有用。我对更好的解决方案持开放态度。


0
投票

据我所知,您只能在连接时更改远程主机的分辨率。

根据您使用的工具,查找远程桌面大小设置,例如在命令行上:

mstsc /w:1440 /h:900 /v:remote_host
© www.soinside.com 2019 - 2024. All rights reserved.