Hyper-V generation 2 VM conversion utility (Convert-VMGeneration)

Convert-VMGeneration converts a Hyper-V generation 1 virtual machine running on Windows Server 2012 R2 or Windows 8.1 to generation 2.

 
 
 
 
 
4.6 Star
(89)
Add to favorites
12/12/2013
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • MBR2GPT
    4 Posts | Last post September 03, 2019
    • Hi! For anyone still looking at this, there is now a better solution in the form of an official Microsoft tool included as of version 1703.
      
      MBR2GPT: https://technet.microsoft.com/en-us/itpro/windows/deploy/mbr-to-gpt?f=255&MSPPError=-2147217396
      
      Create a new Gen-2 VM without a disk, copy your Gen-1's .vhdx to the new VM's storage, attach it to the VM, boot up Win10 1703 media, and run MRB2GPT. Reboot, and you're running as a Gen-2. If you do it in this manner, it is also non-destructive. If it doesn't work, delete your Gen-2 VM and simply turn the old Gen-1 back on.
    • Does this work for Server 2016 VM's?
    • John, yes, works like a charm!
      My situation: 2012 R2 Hyper-V host with gen1 VM's, and a new 2016 Hyper-V host. Surface Book with Win10 build 1703. I simply mounted the gen1 .vhdx over the network on my Surface, ran MBR2GPT.exe, and 10 seconds later the disk was converted to GPT. After that, I created a new gen2 VM on the 2016 host, copied and mounted the vhdx, and the VM works!
    • Me funciono a la perfección, gracias por el dato de esta aplicación.
  • Conversion of Server 2016 fails
    3 Posts | Last post August 27, 2019
    • Hi,
      
      I want to convert a 2016 V1 to V2 and I get the message:
      INFO:    Found Betriebssystem Microsoft® Windows® 10.0.14393.1715 (rs1_release_inmarket.170906-1810) x64 at F:\windows
      
      Could not determine OS version from source disk.
      
      I tried all the solutions in the blog with other lines in the script but it didn't helped me...any ideas?
      Chris
    • Did you get this working? I too am in the situation where I have a server 2016 vm that is gen 1 that i am trying to convert to gen 2. I cannot get past the Could not determine OS version from source disk.
    • When converting my Server 2016 image, i was getting error 672 "Source OS must be version 6.2 (Windows 8/Windows Server 2012) or later."
      
      Lines 1052 to 1065 of the script are responsible for determining the OS version. Specifically line 1055 states "# Split the file version into constituent parts and make sure its in the format a.b.cccc.ddddd (well at least four parts)"
      
      With Server 2016 having a version number of 10, instead of a single digit, is the script interpriting 10 as 1? 
      
      When I made the following change to line 1063 I got past the error
      FROM: if ($SourceOSVersionParts[0] -lt 6) { CleanUp "Source OS must be version 6.2 (Windows 8/Windows Server 2012) or later." }
      
      TO: if ($SourceOSVersionParts[0] -lt 1) { CleanUp "Source OS must be version 6.2 (Windows 8/Windows Server 2012) or later." }
  • Running into the following Host 2016 DC and Guest is 2016 DC Gen1
    2 Posts | Last post May 14, 2019
    • .\Convert-VMGeneration.ps1 -VMName "NS2" -Path C:\ClusterStorage\Volume31 -NoPSVersionCheck
      
      Hyper-V Generation 2 Virtual Machine Conversion Utility. Version 1.04, 6th Dec 2013.
      John Howard, Hyper-V Team, Microsoft Corporation (http://blogs.technet.com/jhoward)
      http://code.msdn.microsoft.com/ConvertVMGeneration
      
      INFO:    Locating virtual machine 'NS2'...
      INFO:    Validating virtual machine configuration...
      
      Exception in main execution
      System.Management.Automation.ArgumentTransformationMetadataException: Cannot convert the "VirtualMachine (Name = 'NS2') [Id = '454d5870-c4e9-42ff-9f87-946ddca32857'
      ]" value of type "Microsoft.HyperV.PowerShell.VirtualMachine" to type "Microsoft.HyperV.PowerShell.VirtualMachine". ---> System.Management.Automation.PSInvalidCastE
      xception: Cannot convert the "VirtualMachine (Name = 'NS2') [Id = '454d5870-c4e9-42ff-9f87-946ddca32857']" value of type "Microsoft.HyperV.PowerShell.VirtualMachine
      " to type "Microsoft.HyperV.PowerShell.VirtualMachine".
         at System.Management.Automation.LanguagePrimitives.ThrowInvalidCastException(Object valueToConvert, Type resultType)
         at System.Management.Automation.LanguagePrimitives.ConvertNoConversion(Object valueToConvert, Type resultType, Boolean recurse, PSObject originalValueToConvert,
      IFormatProvider formatProvider, TypeTable backupTable)
         at System.Management.Automation.LanguagePrimitives.ConversionData`1.Invoke(Object valueToConvert, Type resultType, Boolean recurse, PSObject originalValueToConve
      rt, IFormatProvider formatProvider, TypeTable backupTable)
         at System.Management.Automation.LanguagePrimitives.ConvertTo(Object valueToConvert, Type resultType, Boolean recursion, IFormatProvider formatProvider, TypeTable
       backupTypeTable)
         at System.Management.Automation.ArgumentTypeConverterAttribute.Transform(EngineIntrinsics engineIntrinsics, Object inputData, Boolean bindingParameters, Boolean
      bindingScriptCmdlet)
    • I have the same error. I have Windows Server 2019.
  • Trace 620 No Drive Letter assigned
    1 Posts | Last post September 02, 2018
    • In my case the script struggled over the StorageSetting.
      
      Set-StorageSetting -NewDiskPolicy OnlineAll
      
      When Mount-diskimage were mounting the disk offline, no drive letters were assigned. Online all was working well.
  • Fails due lack of free space
    1 Posts | Last post August 26, 2018
    • My Hyper-V host does not have enough free space for the conversion.
      How can i specify another drive for the temporary operations, that the script does?
  • Please help: Error Code 90662
    1 Posts | Last post July 12, 2018
    • PS C:\Treiber_News> .\Convert-VMGeneration.ps1 -VMName "BUHA" -Path C:\TEMP
      
      INFO:    Locating virtual machine 'BUHA'...
      INFO:    Validating virtual machine configuration...
      INFO:    Identified boot disk is '\\san01-srv\san01-srv$\Hyper-V\Virtual Hard Disks\TEMP\BUHA01-PC\Virtual Hard Disks\BU
      HA01-PC1.vhdx'
      WARNUNG: Partition 3, type Unknown, size 471859200 at offset 128368771072 on disk 1
      (\\san01-srv\san01-srv$\Hyper-V\Virtual Hard Disks\TEMP\BUHA01-PC\Virtual Hard Disks\BUHA01-PC1.vhdx) does not have a
      drive letter and will be ignored
      INFO:    Source drive letters are D E
      Exception in Validate-SourceWindowsInstallation: System.Management.Automation.MethodInvocationException: Ausnahme beim A
      ufrufen von ".ctor" mit 3 Argument(en):  "Das System kann auf die Datei nicht zugreifen.
      " ---> System.IO.IOException: Das System kann auf die Datei nicht zugreifen.
      
         bei System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
         bei System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileSha
      re share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boole
      an useLongPath, Boolean checkHost)
         bei System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
         --- Ende der internen Ausnahmestapelüberwachung ---
         bei System.Management.Automation.DotNetAdapter.AuxiliaryConstructorInvoke(MethodInformation methodInformation, Object
      [] arguments, Object[] originalArguments)
         bei System.Management.Automation.DotNetAdapter.ConstructorInvokeDotNet(Type type, ConstructorInfo[] constructors, Obj
      ect[] arguments)
         bei Microsoft.PowerShell.Commands.NewObjectCommand.CallConstructor(Type type, ConstructorInfo[] constructors, Object[
      ] args)
      
      Exception in Validate-SourceWindowsInstallation
      
      Completed with error. Trace status code 90662
  • Completed with error. Trace status code 91110
    1 Posts | Last post May 24, 2018
    • Trying to convert 2012 r2 gen 1 to gen 2 and got this error. Any help would be appreciated. 
      
      PS C:\scripts> .\Convert-VMGeneration.ps1 -vmname "cccs7" -path "d:\hyper-v\virtual machines"
      
      Verify this maps to 'd:\hyper-v\virtual machines\CCCS7 (Generation 2)\CCCS7-1 (Generation 2).vhdx' in disk management
      (diskmgmt.msc) or diskpart.exe before confirming.
      Your confirmation accepts full liability for accidental data loss due to coding errors or otherwise.
      [N] No  [Y] Yes  [?] Help (default is "N"): y
      INFO:    Preparing disk...
      Exception in Partition-TargetVHDX: System.Management.Automation.CommandNotFoundException: The term '.\diskpart' is not r
      ecognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a p
      ath was included, verify that the path is correct and try again.
         at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exc
      eption)
         at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
         at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
         at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
      
      Exception in Partition-TargetVHDX
      
      Completed with error. Trace status code 91110
  • Completed with error. Trace status code 91510
    5 Posts | Last post May 17, 2018
    • Hi, I ran into the below problem on my Winodws 10 Machine: 
      Convert-VMGeneration.ps1 -VMName "App-V" -Path "D:\Hyper-V\App-V" -NoPSVersionCheck
      
      INFO:    Locating virtual machine 'App-V'...
      INFO:    Validating virtual machine configuration...
      
      Exception in main execution
      System.Management.Automation.ArgumentTransformationMetadataException: Cannot convert the "VirtualMachine (Name = 'App-V') [Id = '24785191-540b-42dd-8fc1-a859955eedbb']" value of type "Microsoft.HyperV.PowerShell.VirtualMachine" to type "Microsoft.HyperV.PowerShell.Virtua
      lMachine". ---> System.Management.Automation.PSInvalidCastException: Cannot convert the "VirtualMachine (Name = 'App-V') [Id = '24785191-540b-42dd-8fc1-a859955eedbb']" value of type "Microsoft.HyperV.PowerShell.VirtualMachine" to type "Microsoft.HyperV.PowerShell.Virtual
      Machine".
         at System.Management.Automation.LanguagePrimitives.ThrowInvalidCastException(Object valueToConvert, Type resultType)
         at System.Management.Automation.LanguagePrimitives.ConvertNoConversion(Object valueToConvert, Type resultType, Boolean recurse, PSObject originalValueToConvert, IFormatProvider formatProvider, TypeTable backupTable)
         at System.Management.Automation.LanguagePrimitives.ConversionData`1.Invoke(Object valueToConvert, Type resultType, Boolean recurse, PSObject originalValueToConvert, IFormatProvider formatProvider, TypeTable backupTable)
         at System.Management.Automation.LanguagePrimitives.ConvertTo(Object valueToConvert, Type resultType, Boolean recursion, IFormatProvider formatProvider, TypeTable backupTypeTable)
         at System.Management.Automation.ArgumentTypeConverterAttribute.Transform(EngineIntrinsics engineIntrinsics, Object inputData, Boolean bindingParameters, Boolean bindingScriptCmdlet)
         -- End of inner exception stack trace --
         at System.Management.Automation.ArgumentTypeConverterAttribute.Transform(EngineIntrinsics engineIntrinsics, Object inputData, Boolean bindingParameters, Boolean bindingScriptCmdlet)
    • Exactly the same error on my side by running the PowerShell command on a Windows 10 machine.
    • There is likely a better way... I had to hack the os version checks for it to work with Win 10.
      
              # Validate that the source is Windows version 6.2 or later (6.2 is Windows 8/Windows Server 2012)
              $script:ProgressPoint = 672
              if ($SourceOSVersionParts[0] -lt 10) { CleanUp "Source OS must be version 6.2 (Windows 8/Windows Server 2012) or later." }
              $script:ProgressPoint = 673
              if (($SourceOSVersionParts[0] -gt 6)) { CleanUp "Source OS must be version 6.2 (Windows 8/Windows Server 2012) or later." }
    • @Lukas - if you haven't figured it out already, the error you got was from not running as administrator.
      
      I used Steve's patch and ran as admin with the -NoPSVersionCheck option under Win 10, and it ran all the way up to Applying Image, but the DISM tool got errors and the script errored out saying:
      
      INFO:    Applying image. This will take some time...
      
      dism /apply-image /imagefile:"Y:\Temp\SPwim" /index:1 /applydir:Z:\ failed  Deployment Image Servicing and Management tool Version: 10.0.10586.0   Error: 87  The parameter is incorrect
      .  The DISM log file can be found at C:\WINDOWS\Logs\DISM\dism.log error code 87
      
      Completed with error. Trace status code 1220
      
      
      The dism.log file had this in it (in a few places):
      2016-07-15 14:22:06, Info                  DISM   DISM Provider Store: PID=6468 TID=5192 Getting the collection of providers from a local provider store type. - CDISMProviderStore::GetProviderCollection
      [6468] [0x8007007b] FIOReadFileIntoBuffer:(1250): The filename, directory name, or volume label syntax is incorrect.
      [6468] [0xc142011c] UnmarshallImageHandleFromDirectory:(793)
      [6468] [0xc142011c] WIMGetMountedImageHandle:(3046)
      2016-07-15 14:22:06, Info                  DISM   DISM WIM Provider: PID=6468 TID=5192 [C:\] is not a WIM mount point. - CWimMountedImageInfo::Initialize
      
      I gave up at that point.
    • @ DStrd - I ran into the same Trace status code 1220 error. Found that it was caused by another image based backup software running a job during the dism process. After a reboot of the 2016 host, and disabling the other backup job, it worked like a champ.
  • Windows 2016 - Gen1 to Gen2 disk error
    1 Posts | Last post March 16, 2018
    • Hi
      
      I get this error on most of the virtual machine I am trying to convert. Any ideas ?
      
      Hyper-V Generation 2 Virtual Machine Conversion Utility. Version 1.04, 6th Dec 2013.
      John Howard, Hyper-V Team, Microsoft Corporation (http://blogs.technet.com/jhoward)
      http://code.msdn.microsoft.com/ConvertVMGeneration
      
      INFO:    Locating virtual machine 'CLSTEST-G2'...
      INFO:    Validating virtual machine configuration...
      INFO:    Identified boot disk is 'C:\ClusterStorage\RSCSTORAGE03\CLSTEST-G2\WS2016-OS.VHDX'
      WARNING: Partition 1, type IFS, size 524288000 at offset 1048576 on disk 14
      (C:\ClusterStorage\RSCSTORAGE03\CLSTEST-G2\WS2016-OS.VHDX) does not have a drive letter and will be ignored
      WARNING: Partition 2, type IFS, size 106847797248 at offset 525336576 on disk 14
      (C:\ClusterStorage\RSCSTORAGE03\CLSTEST-G2\WS2016-OS.VHDX) does not have a drive letter and will be ignored
      
      No partitions on the source disk were assigned drive letters when it was mounted
      
      Completed with error. Trace status code 620
  • Win2k12r2 from Gen1 to Gen2 error
    1 Posts | Last post March 02, 2018
    • PS C:\> .\Convert-VMGeneration.ps1 -VMName "suasrv04 (EPLAN)" -Path "E:\Hyper-V\srv04 (EPLAN)\Virtual Hard Disks" -
      PSVersionCheck
      
      Hyper-V Generation 2 Virtual Machine Conversion Utility. Version 1.04, 6th Dec 2013.
      John Howard, Hyper-V Team, Microsoft Corporation (http://blogs.technet.com/jhoward)
      http://code.msdn.microsoft.com/ConvertVMGeneration
      
      INFO:    Locating virtual machine 'suasrv04 (EPLAN)'...
      INFO:    Validating virtual machine configuration...
      INFO:    Identified boot disk is 'E:\Hyper-V\srv04 (EPLAN)\Virtual Hard Disks\SRV04.VHDX'
      WARNUNG: Partition 1, type IFS, size 2000363192320 at offset 1048576 on disk 2 (E:\Hyper-V\srv04 (EPLAN)\Virtual
      Hard Disks\SRV04-gen2-0.VHDX) does not have a drive letter and will be ignored
      
      No partitions on the source disk were assigned drive letters when it was mounted
      
      Completed with error. Trace status code 620
1 - 10 of 75 Items