Starting a GUI application on a guest VM with PowerShell Direct

梦想的初衷 提交于 2020-06-29 04:06:13

问题


Is it possible to open a window in a current Hyper-V VM session with PowerShell Direct? Or maybe I need to rewords the question as - how to run commands in an existing interactive session that's opened with Hyper-V Remote Desktop Connection?

I have an RDP connection to a Windows Server 2019 VM (Hyper-V), and let's say I want to start notepad.exe from a PowerShell script that runs on a host VM. I want the Notepad window to appear in my current VM's session to take a screenshot (via PowerShell Direct, too, but that's another story).

This snippet starts notepad.exe in background and does not show its window:

Invoke-Command  -VMName 'client1.example.com' -Credential $credential -ScriptBlock {
notepad.exe
}

来源:https://stackoverflow.com/questions/62476454/starting-a-gui-application-on-a-guest-vm-with-powershell-direct

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!