2

I own a remote machine running Windows Server 2012, I created a virtual machine using Hyper-V, installed Windows 7, is possible remotely connect to this virtual machine? How do I do that? Using some other program?

6
  • By remotely connection you mean you would like to remote desktop to the Windows 7 Virtual Machine? If so you can use remote desktop connection (MSTSC) from Windows as long as you have setup your networking correctly on both your Windows Server 2012 box and your Virtual Machine...
    – CharlesH
    Commented Sep 23, 2014 at 9:52
  • Also is this remote connection on the LAN or from an external location (WAN)?
    – CharlesH
    Commented Sep 23, 2014 at 9:53
  • I believe you can connect to a remote Hyper-V virtual machine using Hyper-V manager, but I do not know what is required to do this, so I won't post an answer. But it might help you or others to write an answer.
    – LPChip
    Commented Sep 23, 2014 at 11:25
  • 1
    You will need to set a static IP on the Windows 7 machine and also check you can browse the internet, etc that way you know you have access to the outside world. If that is the case then the virtual machine acts just like a physical machine on its static IP and can have a port forward setup on your router/firewall on port 3389 which will allow remote desktop connection. You also need to enable remote desktop connection in control panel > system > remote settings < allow connections from computers....
    – CharlesH
    Commented Sep 23, 2014 at 12:37
  • 2
    Finally I managed to connect, now it worked, thanks for the comments helped me a lot, I set static IP and was. But taking advantage of the topic, and if I did not have another IP address, how can I perform this procedure? Have some way to connect without a static IP?
    – D3F4ULT
    Commented Sep 23, 2014 at 12:47

1 Answer 1

1

But taking advantage of the topic, and if I did not have another IP address, how can I perform this procedure? Have some way to connect without a static IP?

As you might know, one simple way to connect remotely to a virtual machine is the Enter-PSSession cmdlet. For this method, if you seek to connect a host machine to a virtual machine on HyperV for remote purposes, you don't need any IP configs to be set.

A simple way to achieve this would be to write something like this, assuming you got virtual machines loaded in HyperV:

#Get all the virtual machines from hyperV
#And store them into an object
$virt_mach = Get-VM
#Try with one specific VM
#..You need to start it before
Start-VM -VM $virt_mach[0]
#To Access to a specific Vm with credentials 
#You need to define credentials like this (or with the get-credentials cmdlet)
$user = "DOMAIN\myuser1"
$password = ConvertTo-SecureString "SuperPasswordSoHaRdToFIND" -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential ($user,$password)
#connect to the first VM of the list
Enter-PSSession -VMName $virt_mach[0].Name -Credential $creds
#and then write commandy you need to into the virtual machine
#in here..

To exit the PSSession, just type Exit-PSSession.

Please keep in mind that. This method of Virtual Machine connection ONLY works with O.S, which supports Powershell Direct, which means that this would only work with Windows 10 and Server 2016.

There is no way, in my opinion, to connect remotely to a windows 7 virtual machine from a host machine, other than configuring manually the setup you were talking about before (setting IP addresses, adding the virtual machine to trusted domains, etc.).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .