Reputation: 11621
Set up:
Aim:
How can I achieve this?
Upvotes: 135
Views: 374201
Reputation: 4720
In addition to the excellent answers above that gives me access to resources on my host drive (Windows 11 host, Win 2022 VM) as "Redirected drives and folders" I wanted to use the drive from the command line in the VM (powershell) and got
PS C:\Users\Administrator> e:
Set-Location : Cannot find drive. A drive with the name 'E' does not exist.
At line:1 char:1
+ Set-Location $MyInvocation.MyCommand.Name
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (E:String) [Set-Location], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
The solution for me was to run net use
to display the resources being accessed by the VM and then map the drive:
Show the resources:
PS C:\Users\Administrator> net use
New connections will be remembered.
Status Local Remote Network
-------------------------------------------------------------------------------
\\TSCLIENT\E Microsoft Terminal Services
The command completed successfully.
Map the drive:
PS C:\Users\Administrator> net use e: \\TSCLIENT\E
The command completed successfully.
Drive now available on commandline and in explorer.
PS C:\Users\Administrator> e:
PS E:\> ls
Directory: E:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 16/09/2024 10:52 jenkins
Naturally this will suffer the same limitations as other mapped drives that are not available in background services etc, but it suited my purpose.
Upvotes: 1
Reputation: 117
For those who are having trouble getting the "Edit Session Settings..." dialog, I found that I could get to the dialog box by having the guest machine running in windowed mode so that the top menu ("File Action Media Clipboard View Help") was visible, then selecting "File > Exit" (or clicking on the "X" at the top right of the guest machine window).
After that, the dialog would launch from the Hyper-V Manager Actions "Edit Session Settings..." link.
Upvotes: 10
Reputation: 34627
The virtual machine must have Remote Desktop Services enabled, and run Windows 10, Windows 8.1, Windows Server 2016, or Windows Server 2012 R2 as the guest operating system.
Ensure that Enhanced session mode settings are enabled on the Hyper-V host.
Start Hyper-V Manager, and in the Actions section, select "Hyper-V Settings".
Make sure that enhanced session mode is allowed in the Server section. Then, make sure that the enhanced session mode is available in the User section.
Enable Hyper-V Guest Services for your virtual machine
Right-click on Virtual Machine > Settings. Select the Integration Services in the left-lower corner of the menu. Check Guest Service and click OK.
Start a virtual machine and click Show Options in the pop-up windows.
Or click "Edit Session Settings..." in the Actions panel on the right
It may only appear when you're (able to get) connected to it. If it doesn't appear try Starting and then Connecting to the VM while paying close attention to the panel in the Hyper-V Manager.
View local resources. Then, select the "More..." menu.
From there, you can choose which devices to share. Removable drives are especially useful for file sharing.
Choose to "Save my settings for future connections to this virtual machine".
Click Connect. Drive sharing is now complete, and you will see the shared drive in this PC > Network Locations section of Windows Explorer after using the enhanced session mode to sigh to the VM. You should now be able to copy files from a physical machine and paste them into a virtual machine, and vice versa.
Source (and for more info): Share Files, Folders or Drives Between Host and Hyper-V Virtual Machine
Upvotes: 203
Reputation: 7
My version is Hyper-V Version: 10.0.22509.1000,I think the best and most convenient way in windows is that configuring the host and the vm in the same subnet,So you can just use the ctrl+c and ctrl+v Seamlessly between host and vm.
Upvotes: -4
Reputation: 11621
There is also an easy way for copying via the clipboard:
Upvotes: 72