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

问题描述:

我一直在尝试通过Powershell远程会话设置远程计算机的屏幕分辨率。我可以从Get-DisplayResolution cmdlet中获得解决方案,然后返回以下内容。Powershell远程会话,似乎无法设置屏幕分辨率?

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:\> 

有没有人知道解决这个问题的方法?先谢谢你。

+0

您提到的命令可能会返回会话的分辨率,而不是控制台,它不支持更改(可能根本没有分辨率,而只是返回默认值或分辨率配置文件设置为在登录时使用)。尝试更改控制台上的分辨率,看看它是否反映在您的会话中。 –

+1

您实际上不能在远程会话中更改分辨率。您应该可以设置默认值,但不能设置活动GUI会话的分辨率。即使远程桌面设置连接的分辨率,显示属性也被禁用。 – Eris

+0

@致命百吉饼如何根据您的建议在控制台上设置分辨率?这是一个运行在vm-ware服务器上的虚拟机。 –

尽管这不是对问题的直接回答,但最终并不像我所希望的那样坚实和清洁解决方案。我发现了一项解决方案,可以让我在可从CI服务器启动的远程机器上执行端到端测试。 [自动化远程桌面会话] https://outofmemoryexception.wordpress.com/2016/03/29/automate-your-remote-desktop-sessions/。希望你会发现它也适用于你的场景。我仍然乐于提供更好的解决方案