none
Import-VM -register but different vhdx location

    คำถาม

  • Hi,

    I did an export of various VMs only with configuration from source server:

    https://social.technet.microsoft.com/wiki/contents/articles/1350.hyper-v-export-vm-config-only-using-powershell.aspx

    Than I did a copy of the created MachineFolder to the destination server. The vhds were staying on source server.

    Than I was able to import the VMs on another server using the REGISTER Option of import GUI of hyper-v manager. The GUI noticed that there were no VHDX files and no Virtual Harddisk Folder and ask for the VHDX destination (This is the source servers SMB3 share).

    it works fine.


    Question:

    I have 20 VMs and would like to use powershell to import, but I couln't find any option to say that the VHDs are not inplace.

    I was using:

    Import-VM  -Register  -Path 'D:\Hyper-V\FSB001\Virtual Machines\662F2226-EF9F-4801-8075-3EA2CF7A8700.XML'

    $report.Incompatibilities showed me that he looks for VHDs on the old path of the source server.

    -VhdSourcePath or -VhdDestinationPath doesn't work


    Can anyone point me in the right direction? The gui works, there must be a way with powershell.

    Regards Thomas


    • แก้ไขโดย Thoma 13 มิถุนายน 2561 19:48
    13 มิถุนายน 2561 19:47

คำตอบ

  • the solution is:

    Set-VMHardDiskDrive $report.Incompatibilities[0].Source  -Path '\\SMBshare\Hyper-V\VHDs\W2k8R2-Ora02.vhdx'
    import-vm -compatibilityreport $report

    if there are more than one disks you have to iterate through the array

    found from there and adapted:

    http://askme4tech.com/export-import-virtual-machine-hyper-v-powershell
    https://blogs.msdn.microsoft.com/virtual_pc_guy/2014/04/14/importing-a-vm-with-vhds-in-different-paths/


    • แก้ไขโดย Thoma 13 มิถุนายน 2561 21:21
    • เสนอเป็นคำตอบโดย Michael HxyMicrosoft 14 มิถุนายน 2561 9:36
    • ทำเครื่องหมายเป็นคำตอบโดย Thoma 14 มิถุนายน 2561 14:01
    13 มิถุนายน 2561 21:18

ตอบทั้งหมด

  • the solution is:

    Set-VMHardDiskDrive $report.Incompatibilities[0].Source  -Path '\\SMBshare\Hyper-V\VHDs\W2k8R2-Ora02.vhdx'
    import-vm -compatibilityreport $report

    if there are more than one disks you have to iterate through the array

    found from there and adapted:

    http://askme4tech.com/export-import-virtual-machine-hyper-v-powershell
    https://blogs.msdn.microsoft.com/virtual_pc_guy/2014/04/14/importing-a-vm-with-vhds-in-different-paths/


    • แก้ไขโดย Thoma 13 มิถุนายน 2561 21:21
    • เสนอเป็นคำตอบโดย Michael HxyMicrosoft 14 มิถุนายน 2561 9:36
    • ทำเครื่องหมายเป็นคำตอบโดย Thoma 14 มิถุนายน 2561 14:01
    13 มิถุนายน 2561 21:18
  • Hi,

    Thank you for sharing the solution to this issue, I learn more from your reply, and I believe partners who may visit this thread in the future will benefit from your sharing.

    Best regards,

    Michael


    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    14 มิถุนายน 2561 9:36