Convert-WindowsImage.ps1 — WIM2VHD for Windows 10 (also Windows 8 and 8.1)

Convert-WindowsImage is the new version of WIM2VHD designed specifically for Windows 8 and above. Written in PowerShell, this command-line tool allows you to rapidly create sysprepped VHDX and VHDX images from setup media for Windows 7/Server 2008 R2, Windows 8/8.1/Server 2012/R2

4.6 Star
139,129 times
Add to favorites
E-mail Twitter Digg Facebook
  • Windows Server 2016 - is this supported?
    3 Posts | Last post October 14, 2016
    • PS C:\tools> Convert-WindowsImage -SourcePath "c:\tools\en_windows_server_2016_x64_dvd_9327751.iso" -Edition "Windows Server 2016 Datacenter (Desktop Experience)" -vhdpath c:\tools\2016.vhdx -vhdformat VHDX -SizeBytes 40GB
      Windows(R) Image to Virtual Hard Disk Converter for Windows(R) 10
      Copyright (C) Microsoft Corporation.  All rights reserved.
      Version 10.0.9000.0.amd64fre.fbl_core1_hyp_dev(mikekol).141224-3000 Beta
      INFO   : Opening ISO en_windows_server_2016_x64_dvd_9327751.iso...
      INFO   : Looking for D:\sources\install.wim...
      INFO   : Image  selected ()...
      ERROR  : Convert-WindowsImage only supports Windows 7 and Windows 8 WIM files.  The specified image does not appear to contain one of those operating systems.
    • The problem was with the -Edition parameter.  I got this info out of DISM, but should have just left off the parameter as the cmdlet let me know what it needed:
      ERROR  : You must specify an Edition or SKU index, since the WIM has more than one image.
      ERROR  : Valid edition names are:
      ERROR  :   ServerStandardCore
      ERROR  :   ServerStandard
      ERROR  :   ServerDataCenterCore
      ERROR  :   ServerDataCenter
      ERROR  : ScriptHalted
      This syntax works:
      Convert-WindowsImage -SourcePath "c:\tools\en_windows_server_2016_x64_dvd_9327751.iso" -Edition serverDatacenter -vhdpath c:\tools\2016.vhdx -vhdformat VHDX -SizeBytes 40GB
    • this isn't even working for me, still keeps giving me the same error about editions.  If I open the GUI it gives me an error about path being NULL.
  • Dot Source Script
    2 Posts | Last post September 12, 2016
    • I'm only dot sourcing the script but it already gives me the error:
      The script failed due to call depth overflow.
          + CategoryInfo          : InvalidOperation: (0:Int32) [], ParentContainsErrorRecordException
          + FullyQualifiedErrorId : CallDepthOverflow
    • Never mind, re-download of the script solved it.
  • Trouble with "Edition" parameter
    2 Posts | Last post August 12, 2016
    • I have configured and captured a Windows 10 Professional WIM. I am using the following syntax:
      /Convert-WindowsImage -SourcePath E:\win10Pro.wim -Edition Professional -VHDPath e:\test.vhd -VHDFormat vhd/
      I get the following error: 
      /The variable cannot be validated because the value  is not a valid value for the Edition variable./
      I used dism to verify that the wim contains:
      /Index : 1
      Name : Windows 10 Professional
      Description : <undefined>
      Size : 18,078,034,489 bytes/
      So, I tried "Windows 10 Professional" for the -Edition parameter and got the same error. 
    • You can fix this by using Imagex.exe /flags and setting the image flag.
  • Image-Version Error
    5 Posts | Last post August 05, 2016
    • Hello@all,
      I have this error:
      "Convert-WindowsImage only supports Windows 7 and Windows 8 WIM files.  The specified image does not appear to contain one of those operating systems."
      Someone an idea to fix this. My skills in PS are modest.
    • Forget the Info which OS i try - Server 2012R2
    • Ok, i found the Problem. I starting the script from the same Directory who the .ISO in there.
      Thanks for the REALLY good WORK!
    • Hi Mike,
      I am not clear as to how you made it to work.
      I am seeing the same exact error you have mentioned when creating a Win2012R2 vhd.
      Can you please let me know how got past this error?
    • @BarathV
      When calling the function ensure that you use the full path to the ISO or WIM.
      E.g. use
      Convert-WindowsImage -SourcePath "C:\MyDownloads\myISO.iso"
      instead of
      Convert-WindowsImage -SourcePath ".\myISO.iso"
  • It does not work...
    7 Posts | Last post July 31, 2016
    • Hello!
      This problem, run ". \ Convert-WindowsImage.ps1 -ShowUI" but nothing happens. Help me please!
      Thank you!
    • Open the script with PoewrShell ISE rather than plain Powershell, and as admin.
      you´ll see the function in the editor.
      Scroll down, and write the call to the function right at the end, after the function as:
      Convert-WindowsImage -ShowUI
      Execute the whole script within PowerShell ISE. You´ll see the UI Windows, etc.
    • Cesar, I see your answer for "write the call" but for those of us that do not code, can you be more clear?
    • You have to write an additional line at the bottom of the script containing the call to the function (Convert-WindowsImage) followed by the command line options in case you where trying the command line options from the first post it would be:
      Convert-WindowsImage -ShowUI
      The run the script from the play button at the ISE toolbar or save it and execute it form the command input.
    • It seems the UI is failing in many cases. I ended using this call to the function, editing with PowerShell ISE in admin modeand adding the following line at the end of the file:
      Convert-WindowsImage -SourcePath H:\WIN10.ISO -VHDPath C:\VHDs\WINDOWS10.VHDX -VHDFormat VHDX -SizeBytes 100GB -Edition Professional
       and finally running the whole script from PowerShell ISE.
    • Putting the line at end of the file worked for me like Cesar Said.
      Thanks Cesar.
      I used following command - 
      Convert-WindowsImage -SourcePath I:\sources\install.wim -SKU ServerDataCenter -VHDFormat VHD -WorkingDirectory $pwd -VHDType Dynamic -VHDPartitionStyle MBR
    • Is this really supposed to be this hard to use? I've tried everything listed here and all I ever get is "ERROR  : You cannot call a method on a null-valued expression." What are the actual steps to run this script?
  • Issue with Edition
    2 Posts | Last post June 07, 2016
    • When trying to run:
          PS E:\wim2vhd> Convert-WindowsImage -SourcePath .\Win7-ProfileTest.wim
      I get this error:
          ERROR  : The variable cannot be validated because the value  is not a valid value for the Edition variable.
      The WIM in question is Windows 7 Ultimate x64. It is a machine build captured with DISM. 
      Get-WindowsImage run on the WIM gives me:
          PS E:\wim2vhd> Get-WindowsImage -ImagePath .\Win7-ProfileTest.wim
          Index       : 1
          Name        : Win7-ProfileTest
          Description :
          Size        : 24,362,817,859 bytes
      I've tried passing the following (individually) to -Edition: 1, Ultimate, Windows7Ultimate, Win7-ProfileTest. They all give the same error above. 
      If I try to load the WIM using Convert-WindowsImage -ShowUI I get an unhandled exception relating to "Cannot validate argument on parameter 'Path'. Details here:
      Any help would be appreciated.
    • Fixed by changing line 4075 from:
          $Edition   = $openWim.Images[0].ImageFlags
          $Edition   = $openWim.Images[0].ImageName
      as mentioned by Daniel Scott-Raynsford below.
  • Script error ?
    1 Posts | Last post June 02, 2016
    • The foreach-loop processing $Edition seems to mistakenly assign $PSItem to the variable $Edition for each loop. This should be a separate variable such as $Edtn.
      In my case I've had problems when specifying -edition <an index> and having the script complain that 'string[]' cannot be converted to an integer. Even if I use a name, there's a problem if -Edition specifies multiple items.
  • Error on creating Win2012R2 VHD
    3 Posts | Last post April 26, 2016
    • Hello@all,
      I have this error:
      "Convert-WindowsImage only supports Windows 7 and Windows 8 WIM files.  The specified image does not appear to contain one of those operating systems."
      I am running the script on a win2012r2 server.
      Here are the commands:
      Import-Module .\Convert-WindowsImage.ps1
      Convert-WindowsImage -SourcePath .\9600.17050.WINBLUE_REFRESH.140317-1640_X64FRE_SERVER_EVAL_EN-US-IR3_SS
      _X64FREE_EN-US_DV9.ISO -VHDFormat VHD -Edition ServerDataCenter -VHDPartitionStyle MBR -Driver .\NewDriver -Verbose
    • I've spent about 3 days resolving the problem with Windows Server 2012R2 error I had with the Eval version:
      ERROR  : Exception calling "Apply" with "1" argument(s): "The file or directory is corrupted and unreadable".
      Then I tried to mount the iso to Hyper-V and install the server manually. But I had the alert: Windows cannot find the Microsoft Software License Terms.  Make sure the installation sources are valid and restart the installation.
      So, I tried to use usual iso image from VL site changing -Edition to ServerStandard. And hopefully it worked for me.
    • Also, I've found a workaround how to fix the alert:
  • Cannot bind argument to parameter 'Path' because it is null
    2 Posts | Last post April 11, 2016
    • Downloaded the script for the first time today (2016-03-20) but keep getting this error.
      Not a Powershell expert but I believe this is an error in the script itself.
      I started with Import-Module .\Convert-WindowsImage.ps1
      However, whatever method I use to run the function, I always get this error.
      Any help would be appreciated.
    • Solved it by executing it with a 64 bit processor, hopes this helps
  • Adding unattend
    2 Posts | Last post Thu 9:26 AM
    • I've downloaded the script executed it using the -UnattendPath option. Vhdx gets created it, but when I try to mount the vhdx to a virtual machine, it tells me it can't parse or process the unattend file on it. When I try to mount the disk, on the host, I see the file is on it. Any idea what the problem could be ? I'am using the unattend file generated by Windows Answer file generator. Also making a vhdx without unattend option, allows me to install the os on the guest-os. Has anybody succeeded in creating a vhdx with the unattended option and be able to mount in HyperV? 
    • Problem solved, was a fault in the unattended file where NTFS was used as disk format while it should be vhdx.
41 - 50 of 154 Items