Import a Hyper-V Virtual Machine with PowerShell
I recently ran into a problem where an exported VM from Windows Server 2016 running Hyper-V wasn't able to be imported on Windows Server 2019 running Hyper-V. When attempting to perform the import, the GUI stated "No virtual machines files found" as shown in the following image. This problem may have been due to using Hyper-V manager on a remote system running Windows Server 2012 R2, although the same system was used for the export.
Since the Hyper-V servers themselves were installed with the Server Core installation option (no GUI), I decided to try importing the VM with PowerShell instead. I was able to successfully import it using the following command.
1Import-VM -Path '.\Virtual Machines\BD64EDC0-CD9B-4EFE-8F42-D3EBD9A6F522.vmcx' -Copy -GenerateNewId -VirtualMachinePath D:\ -VhdDestinationPath 'D:\Server01\Virtual Hard Disks\' -SnapshotFilePath D:\Server01\ -SmartPagingFilePath D:\Server01\
What I also learned is that if the Hyper-V configuration files exist on a volume on a storage device such as a SAN and that entire volume is connected to the new server, you can simply import the VM without needing to perform an export first. It appears that all an export does is copy the VHD/VHDX files, configuration files, snapshots, etc.
1Import-VM -Path '.\Virtual Machines\BD64EDC0-CD9B-4EFE-8F42-D3EBD9A6F522.vmcx' -Register
The previous command performs a "Register in-place" of the VM instead of performing a copy of the files. It assumes that you already have the correct file structure in place as would be the case for performing a simple migration of a storage volume and VM to a new Hyper-V server.