- Hyper-V keeps VM config at
%ProgramData%\Microsoft\Windows\Hyper-V\Virtual Machines\
as a symbolic link (aka symlink) to the original location.
You may get them broken due to various reasons, e.g.:
- Server disaster and then recovery
- Upgrade to the next version of OS/Hyper-V and then rollback
- Migration of virtual machine
To restore functioning you need to create a symlink for each xml config, i.e.:
mklink %ProgramData%\Microsoft\Windows\Hyper-V\Virtual Machines\{guid}.xml d:\MyVM\Virtual Machines\{guid}.xml
But how to automate this if you have tens of VMs? Here’s the command:
Get-ChildItem -Recurse *.xml | `
New-Symlink -LiteralPath { Join-Path -Path '%ProgramData%\Microsoft\Windows\Hyper-V\Virtual Machines' -ChildPath $_.Name } -TargetPath { $_.FullName }