Manage Learn to apply best practices and optimize your operations.

No network connection needed with Virtual Machine Connection tool

The Virtual Machine Connection tool lets users copy files and redirect local resources to a VM without a network connection.

The Virtual Machine Connection tool allows users to connect to the console of a virtual machine running on the...

Hyper-V server, and has been available since the first release of Hyper-V. The tool supports the ability to perform a number of common tasks. Starting with Windows Server 2012 R2, it is now possible to redirect local resources to VMs and copy files to them without requiring a network connection.

Redirecting Local Resources

There are several local resources that can be redirected when connecting to a VM running on a Hyper-V 2012 R2 host, including display configuration, audio, printers, clipboard, local drives, smart cards, USB devices, and plug and play (PnP) devices. Once Enhanced Session Mode is enabled on the Hyper-V server and you connect to a VM that supports local resources redirection, you can switch to the Local Resources tab. In that tab, you can select or deselect the resources you want to be redirected with the Virtual Machine Connection tool. For example, you can select local drives, printers and clipboard, as shown in Figure 1.

Local Resources
Figure 1

By default, Enhanced Session Mode enables the redirection of display configuration, printers and clipboard. Redirecting printers makes VM printing available to the local printer attached to the Hyper-V host, and clipboard redirection enables copy/paste functionality over the VM session.

One positive about Enhanced Session Mode is that it is possible to redirect local drives and PnP devices, which are injected after the session is established. All you need to do is to check the "Drives that I plug in later" setting for local drives and "Devices that I plug in later" setting for other PnP devices, as shown in the screenshot above. Whenever you inject a USB flash drive or attach a local drive to the Hyper-V host, the session mode will make sure the device is available to the current VM session without re-establishing the session. The redirection of RemoteFX USB devices might not work because of a Group Policy that is not configured by default. You might want to enable the "Allow RDP redirection of other supported RemoteFX USB devices from the computer" policy in the VM. The Group Policy Object, or GPO, policy is located under the "Computer Configuration\Administrative Templates\Windows Components\Remote Desktop Services\RemoteFX USB Device Redirection" node.

The display configuration redirection now supports Full Screen mode for the VM. All you need to do is to move the slider in the Display Configuration until the value reaches "Full Screen," as shown in Figure 2.

There is no need to select or deselect the resources you want to redirect every time you connect to a VM through the Virtual Machine Connection tool. Simply check the "Save my settings for future connections for this virtual machine" option, as shown in Figure 2.

Display Configuration
Figure 2

The settings for the resources to be redirected are saved in the folder called \Users\%UserName%\AppData\Roaming\Microsoft\Windows\Hyper-V\Client\1.0. A file by name "vmconnect.rdp.GUID of the VM.Config" is created for each VM. Next time when you connect to the VM using the Virtual Machine Connection tool or click the "Connect" action from the Hyper-V Manager, whatever resources you had selected for redirection will be available to you automatically.

In case you need to modify the session settings or the local resources to be redirected, you can do so by right-clicking on the VM in the Hyper-V Manager and selecting the "Edit Session Settings," as shown in Figure 3.

Edit Session Settings
Figure 3

Next time when you connect to the VM from Hyper-V Manager, the VM session will always be established when using Enhanced Session Mode.

Copying files to a VM

In previous versions of Hyper-V, you needed to shut down the VM before you could copy the file to it. A traditional approach would be to shut down the VM, mount the VHD file using Windows Explorer and then copy the file. Although Enhanced Session Mode allows you to copy files by using clipboard redirection, it is limited to the current VM session. If you need to copy a file to all VMs on a host, you can do so by using the Copy-VMFile PowerShell cmdlet.

Hyper-V 2012 R2 Integration Services added a new service called guest services, which helps users copy the files to the VMs without a network connection. Before you can use the Copy-VMFile PowerShell cmdlet, make sure you have enabled guest services on the property page of the VM, as shown in Figure 4.

Guest Services
Figure 4

Apart from enabling guest services on the property page of the VM, you also need to ensure that the Hyper-V Guest Service Interface service is running inside the VM.

You can also enable guest services for all VMs or just one by executing the following PowerShell commands:

To enable for a specific VM:

  • Get-VM -Name VM1-Win812 | Enable-VMIntegrationService -Name "Guest Service Interface"

To enable for all VMs:

  • Get-VM | Enable-VMIntegrationService -Name "Guest Service Interface"

Once Guest Services is enabled, you can use the Copy-VMFile PowerShell cmdlet to copy files to one or all VMs using these commands:

To copy a file to a single VM:

  • Copy-VMFile "VM1-Win812" –SourcePath "D:\LabFiles\HowTo.DOCX" –DestinationPath "C:\LAbFiles\HowTo.DOCX" –CreateFullPath –FileSource host

That command copies a file from the source D:\LabFiles to a single VM named "VM1-Win812." In case you need to copy a file to multiple VMs, use the –Name parameter with the command and specify the names of the VMs, separated by commas, as stated in this command:

  • Copy-VMFile –Name VM1, VM2, VM3 –SourcePath "D:\LabFiles\HowTo.DOCX" –DestinationPath "C:\LAbFiles\HowTo.DOCX" –CreateFullPath –FileSource host

In case the file already exists in the VM, you can use the –Force switch with the command to overwrite the file, as shown in the command below:

  • Copy-VMFile –Name VM1, VM2, VM3 –SourcePath "D:\LabFiles\HowTo.DOCX" –DestinationPath "C:\LAbFiles\HowTo.DOCX" –CreateFullPath –FileSource host -Force

Hyper-V 2012 R2 brings a lot of new enhancements and features. It becomes easy for virtual administrators, test developers and users to redirect the local resources and copy files to a VM without requiring a networking connection with the help of Enhanced Session Mode and guest services features.

This was last published in November 2014

Dig Deeper on Using virtual machine appliances

PRO+

Content

Find more PRO+ content and other member only offers, here.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchVMware

SearchWindowsServer

SearchCloudComputing

SearchVirtualDesktop

SearchDataCenter

Close