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.7 Star
(161)
97,087 times
Add to favorites
Storage
6/19/2015
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Maybe,,, it has a bug in using $Edition variable
    4 Posts | Last post January 13, 2017
    • "$Edition = $PSItem" in the below has a problem,
      
      "
      $Edition | ForEach-Object -Process {
      
          $Edition = $PSItem
          
          if ([Int32]::TryParse($Edition, [ref]$null)) {
              $openImage = $openWim[[Int32]$Edition]  // throw exceptions in some cases
          } else {
              $openImage = $openWim[$Edition]
          }    
      
          ...[omitted for brevity]...
      }
      "
      
      This seems to be fixed like this,
      
      "
      $Edition | ForEach-Object -Process {
      
          $editionItem = $PSItem    // define $editionItem separetely
          
          if ([Int32]::TryParse($Edition, [ref]$null)) {
              $openImage = $openWim[[Int32]$editionItem]  // use $editionItem
          } else {
              $openImage = $openWim[$Edition]
          }    
      
          ...[omitted for brevity]...
      }
      "
      
    • Yes, the Edition variable is defined as "String Array" by mistake in line 176 and must be defined as "String".
      
      174  [Parameter(ParameterSetName="SRC")]
      175  [Alias("SKU")]
      176  [string[]]
      177  [ValidateNotNullOrEmpty()]
      178  $Edition,
      
      Delete the extra [] and fix line 176 to:
      176  [string]
      
      After this correction the script can accept the Edition Parameter as Index number or name.
    • I'm still getting the error (Windows 10 Enterprise 1607 OS running PowerShell as admin converting Windows 10 Enterprise 1607, Windows Server 2012 R2, or Windows Server 2016 so far):
      Cannot bind argument to parameter 'Path' because it is an empty string. I have tried individually and together both of the modifications listed to lines 176 and 4190. Any ideas?
      BTW - Amazing script! I really miss it now that it's not working for me.
    • Tried to apply changes but still getting the same error (Windows 10 pro 1607 )
  • Cannot validate argument on parameter 'Path
    2 Posts | Last post January 13, 2017
    • So I run the Powershell as admin, I run the following
      set-executionpolicy unrestricted -force
      . .\Convert-WindowsImage.ps1
      convert-windowsimage -ShowUI
      
      I get the GUI I select my WIM as the source and It throws a unexpected exception with the following.. PLEASE HELP
      
      
      System.Management.Automation.ParameterBindingValidationException: Cannot validate argument on parameter 'Path'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. ---> 
    • same error!!
      unable tu select SKU and unable to convert images using GUI
      
      
      hope this  this will help
      INFO   : Launching UI...
      ERROR  : No source path specified.
      INFO   : Log folder is C:\...\Temp\Convert-WindowsImage\c82ff142-a1fc-4346-8aa2-18c64d82095d
      INFO   : Done.
  • Windows 10.WIM
    1 Posts | Last post January 03, 2017
    • Is V10 of this script supposed to work with a Windows 10.WIM file? Each time I try to run it I get:
      
      PS C:\> convert-windowsimage -SourcePath "C:\WIN10\Win10R1.3_Base.wim" -Edition Enterprise
      
      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   : 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.
      INFO   : Log folder is C:\Users\broregan\AppData\Local\Temp\Convert-WindowsImage\e2cbd0fd-beff-4f9a-874f-968b488497a1
      
      INFO   : Closing Windows image...
      INFO   : Done.
  • Can't get passed line 4064
    1 Posts | Last post December 29, 2016
    • Hi,
      I am not much of a coder so I don't really understand what this portion of the script is trying to do and because the code it wants to load is all passed as a parameter I can't debug it.
      the line 4064 contains
      $openWim     = New-Object WIM2VHD.WimFile $SourcePath
      
      the error is:
      ERROR  : Exception calling ".ctor" with "1" argument(s): "An attempt was made to load a program with an incorrect format"
      
      I am running the script using the following command
      Convert-WindowsImage -SourcePath "E:\Windows ISO\Windows 10 1507.iso" -VHDPath "E:\NativeBoot\StagingVHDXDeploy\Windows10.vhdx" -SizeBytes 40GB -VHDFormat VHDX -VHDType Dynamic -Edition 'Windows 10 Pro' -VHDPartitionStyle GPT -BCDinVHD NativeBoot -RemoteDesktopEnable:$true
      
      thanks
      Steve
  • Server 2016 ISO version
    1 Posts | Last post December 21, 2016
    • Thanks for this script!!
      
      Gernal feedback - Won't run on an Evaluation version of Server 2016 ISO but will run on Server 2016 ISO downloaded from MS Partner benefits site.  
      
      Found through the Jack Stromberg site
      http://jackstromberg.com/2016/06/how-to-deploy-hub-licensed-vms-in-azure/deploy-from-template/
      
      ERROR script
      PS C:\support> Convert-WindowsImage -SourcePath "c:\support\14393.0.160715-1616.RS1_RELEASE_SERVER_EVAL_X64FRE_EN-US.ISO
      " -Edition serverDatacenter -vhdpath c:\support\2016-HUB.vhd -vhdformat VHD -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 14393.0.160715-1616.RS1_RELEASE_SERVER_EVAL_X64FRE_EN-US.ISO...
      INFO   : Looking for F:\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.
      
      
      
      
      SUCCESS script
      
      PS C:\support> Convert-WindowsImage -SourcePath "SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_English_-2_MLF_X21
      -22843.ISO" -VHDFormat VHD -Edition "ServerDataCenter" -VHDPartitionStyle MBR -BCDinVHD NativeBoot -ExpandOnNativeBoot:$
      false -RemoteDesktopEnable -Verbose
      
      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
      
      VERBOSE: isUserAdmin? True
      VERBOSE: is Windows 8 or Higher? True
      VERBOSE: Temporary VHD path is : C:\support\14d846cb-5afc-4cf1-a3a1-15cc3b010872.vhd
      INFO   : Opening ISO SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_English_-2_MLF_X21-22843.ISO...
      INFO   : Looking for F:\sources\install.wim...
      
      INFO   : Image 4 selected (ServerDataCenter)...
      INFO   : Creating sparse disk...
      
  • Parameter help/description is not always correct
    1 Posts | Last post December 20, 2016
    • Heads up,
      
      the parameter help for -VHDPartitionStyle says that by default the script creates a VHDX for a Gen-1 VM in Hyper-V (by using the MBR disk layout). This is not true - when you omit the parameter, the script chooses the GPT layout. Thus, the VHDX can only be used for a Gen-2 VM.
      
      Tested on Windows Server 2016 with a Server 2016 ISO. Here's my command line for reference:
      
      Convert-WindowsImage -SourcePath "H:\ISO\de_windows_server_2016_x64_dvd_9327757.iso" -Edition ServerDataCenter -vhdpath H:\VM\MeinServer.vhdx -vhdformat VHDX -SizeBytes 40GB
      
      And here's what the script says about the disk layout:
      
      INFO   : Attaching VHDX...
      INFO   : Disk initialized with GPT...
      INFO   : Disk partitioned
      INFO   : System Partition created
      INFO   : Boot Partition created
      
  • $Null value for Edition
    2 Posts | Last post November 04, 2016
    • I am trying to run this script on Windows 10 and it keeps saying "ERROR: The variable cannot be validated because the value $null is not a valid value for the Edition variable."
      
      I am specifying the edition variable but I cannot get the script to work. I attempted to apply the fix suggested by user "SeongTae Jeong" but that did not help. Is anyone else experiencing this issue? 
    • The solution had already been posted by Steve Graves on June 07, 2016. It was a change to line 4075. I browsed through the Q&A section but I must have missed it. 
  • Script is not running on any Device
    4 Posts | Last post November 02, 2016
    • I cannot run this script on different machines (W2012R2 or Win8.1)
      If i run the script, nothing happens.
      I tried several things. Powershell started as admin, i unlocked the file after downloading, i set the execution policy to unrestricted.
      
      No -ShowUI or -SourcePath ..... is working.
      
      Can anyone help me?
      
      Regards Sven
    • OK, my mistake.
      Here my own solution. :)
      Just copy and paste the following, to start the UI:
      
      set-executionpolicy unrestricted -force
      . .\Convert-WindowsImage.ps1
      convert-windowsimage -ShowUI
    • WORKED!!!
      http://virtualstation.azurewebsites.net/?p=9551
      
    • Thanks Marcel Otto, you saved my time.
      Worked!!!!!!!!!!!!!! YES!!!!!!!!!!!!!!!!!!!
      also I tried
      . .\Convert-WindowsImage.ps1 (space between . .\)
      convert-
      this will prompt for Convert-WindowsImage.ps1 
      then space and type -showui
  • GUI is throwing an error
    1 Posts | Last post October 14, 2016
    • System.Management.Automation.ParameterBindingValidationException: Cannot bind argument to parameter 'Path' because it is an empty string.
      
      
  • 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.
1 - 10 of 123 Items