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
(88)
Add to favorites
12/12/2013
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Conversion of Server 2016 fails
    2 Posts | Last post June 23, 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.
  • 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
  • Quick fix for Server 2016 / Windows 10
    8 Posts | Last post January 22, 2018
    • The variable reports the OS version as string and when comparing strings "10" is less than "6". 
      So as a quick fix replace Line 1059 with the following:
      
      if (($SourceOSVersionParts[0] -lt 6) -and ($SourceOSVersionParts[0] -ne 10)) { CleanUp "Source OS must be version 6.2 (Windows 8/Windows Server 2012) or later." }
      
      I just converted a Server 2016 VM on a Server 2016 host successfully. 
      Hope this helps.
    • I think the code below is little better.
      
      Lines 1059-1061:
      if ([int]$SourceOSVersionParts[0] -lt 6) { CleanUp "Source OS must be version 6.2 (Windows 8/Windows Server 2012) or later." }
      $script:ProgressPoint = 673
      if (([int]$SourceOSVersionParts[0] -eq 6) -and ([int]$SourceOSVersionParts[1] -lt 2)) { CleanUp "Source OS must be version 6.2 (Windows 8/Windows Server 2012) or later." }
    • Just had the same problem when converting Server 2016 VMs to Gen2. I tried the same thing as Robert and this works.
    • Neither Ingo's nor Robert's did not work for me...
      
      Hyper-V Generation 2 Virtual Machine Conversion Utility. Version 1.04,
      013.
      John Howard, Hyper-V Team, Microsoft Corporation (http://blogs.technet.
      rd)
      http://code.msdn.microsoft.com/ConvertVMGeneration
      
      INFO:    Locating virtual machine 'RS3-G1'...
      INFO:    Validating virtual machine configuration...
      INFO:    Identified boot disk is 'C:\Users\Public\Documents\Hyper-V\Vir
       Disks\RS3-G1.vhdx'
      INFO:    Source drive letters are D E
      INFO:    Found Microsoft® Windows® Operating System 10.0.16294.1 (WinBu
      1.0800) x64 at E:\windows
      
      Could not determine OS version from source disk.
      
      Completed with error. Trace status code 671
    • Ok I go it to work changing 
              # Split the file version into constituent parts and make sure its in the format a.b.cccc.ddddd (well at least four parts)
              $script:ProgressPoint = 670
              $SourceOSVersionParts = $SourceOSVersion.Split(".")
              $script:ProgressPoint = 671
              if ($SourceOSVersionParts.GetUpperBound(0) -ne 4) { CleanUp "Could not determine OS version from source disk."  } 
      
      to
      
              # Split the file version into constituent parts and make sure its in the format a.b.cccc.ddddd (well at least four parts)
              $script:ProgressPoint = 670
              $SourceOSVersionParts = $SourceOSVersion.Split(".")
              $script:ProgressPoint = 671
              if ($SourceOSVersionParts.GetUpperBound(0) -ne 5) { CleanUp "Could not determine OS version from source disk."  } 
      
      
    • Is there an updated download version of this script?  I couldn't by the msgs.  perhaps I am to update the script with the porposed line?  TIA, BillW
    • The solution posted by Robert M. worked for me converting a Windows 10-VM
    • This is what worked for me.
      
      Prior to convert, on VM, NOT host
      reagentc /info		Check Status of Windows RE, if enabled disable if necessary.
      reagentc /disable
      
      After convert on VM
      reagentc /enable
      
      Need to use 64 bit PowerShell and must be run as Administrator
      
      Needed to 'rem out' or update lines 206, 1055, 1059 and 1061 for newer versions and newer OS's
      I had to use the -IgnoreWinRE switch - don't know why. But my VM didn't seem to have a Windows RE
      
      Line 206
      [switch] $NoPSVersionCheck=$True,
      
      line 1055
      if ($SourceOSVersionParts.GetUpperBound(0) -ne 5) { CleanUp "Could not determine OS version from source disk."  }
      
      line 1059
      if ([int]$SourceOSVersionParts[0] -lt 6) { CleanUp "Source OS must be version 6.2 (Windows 8/Windows Server 2012) or later." }
      
      line1061
      if (([int]$SourceOSVersionParts[0] -eq 6) -and ([int]$SourceOSVersionParts[1] -lt 2)) { CleanUp "Source OS must be version 6.2 (Windows 8/Windows Server 2012) or later." }
      
1 - 10 of 75 Items