Sharing of thoughts and information is what blogging is all about. This way we can learn from each other. Post A Comment!These postings are provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use.
Chris Di LulloSr. IT Pro Marketing Manager Twitter | LinkedIn Pierre Roman Twitter | LinkedIn Mitch Garvis Twitter | LinkedIn Anthony Bartolo Twitter | LinkedIn
Note: This article applies equally to the server-side and client-side hypervisor. Although some scenarios may not apply to older versions, the technical steps apply to all versions of Hyper-V released to date.
A virtual machine in Hyper-V consists of a few files that account for its virtual hardware configuration and the virtual storage (VHD and VHDX files). By default the virtual machine configuration files are stored in C:\ProgramData\Microsoft\Windows\Hyper-V, and the virtual hard drives are stored in C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks.
One slight improvement in Hyper-V (in Windows Server 2012) is that during the installation process (GUI mode only) it gives you the option of changing these defaults. However the defaults are still the same as they used to be… on the C drive.
While you can change these file locations on a per-VM basis when you create them, there are several reasons why you might want to change these global default locations within your hosts.
Whatever the reason, here is a simple way to make it happen. Remember, these steps will apply to virtual machines created going forward only, and will not move any pre-existing VMs.
4. Click OK to close the Hyper-V Settings page.
PowerShell Tip: I am often asked ‘Can you do this in PowerShell?’ My usual reply is that PowerShell can do almost anything. So thanks to my #1 PowerShell Resource (PowerShell MVP Sean Kearney) I can provide you with the exact script to accomplish the same task. This method has the added benefit of working on either local or remote Hyper-V hosts, assuming you have the proper credentials.
By the way, you can also string these two together with the following script:
SET-VMHOST –computername <server> -virtualharddiskpath 'C:\VHD' -virtualmachinepath 'C:\VM'
Now when you create a new virtual machine, the files will be stored where you want them, without having to change them manually. It’s simple!