Powershell – non-GUI connection to local Hyper-V VM without network

hyper-vpowershellvirtualization

I have a virtual machine on Hyper-V manager (Windows 2008 R2) without a network configured on the VM. From a powershell script running on the host Windows server, I would like to query into the OS of that local VM for certain information (i.e. if a given process has finished completion).

I am using codeplex's pshyperv module (https://pshyperv.codeplex.com/) to interact with Hyper-V manager, but the only cmdlet to connect to the vm is 'New-VMConnectSession', which launches a 'vmconnect.exe' connection to the VM. Since vmconnect.exe is essentially RDP, this is not very script-friendly.

From within a host's powershell script, is there any way to send a command to a local virtual machine's OS and receive output, if no network is configured on the VM? (I believe Vmware's 'vmrun' utility has this capability)

Another way to ask this question: Does Hyper-V have a non-GUI-based form of vmconnect.exe?

(PS. Not sure if this was more stackoverflow or serverfault)

Best Answer

vmconnect allows a client to connect to the hypervisor. It does use a RDP protocol, typically with the hypervisor acting as the "server". The VM is completely unaware of this interaction, it simply sees a VGA or similar device. On newer OSes where both Hyper-V and the VM OS support certain RDP over VMbus extension, the client is aware of the connection. But even in this case it is not processed over a "network" connection, but rather through the hypervisor.

There are no built-in ways to communicate the way you want to. You could either write a custom VMbus driver that communicates from the host to VM over Hyper-V's virtual bus; or use naped pipes mapped to serial ports; but both of these would require some effort.