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
(181)
144,140 times
Add to favorites
Storage
6/19/2015
E-mail Twitter del.icio.us Digg Facebook
  • Error at Applying Image to VHDX
    1 Posts | Last post October 24, 2018
    • I have got an Windows 10 1803 WIM trying to add the conversion but failing with the following error. 
      
      INFO   : Applying image to VHDX. This could take a while...
      PS>TerminatingError(ForEach-Object): "Exception calling "Apply" with "1" argument(s): "A required privilege is not held by the client""
      ERROR  : Exception calling "Apply" with "1" argument(s): "A required privilege is not held by the client"
      
      Have elevated Powershell 
      
      Anyone else resolved the error?
      
      Bruce
  • ERROR : The system cannot find the file specified.
    2 Posts | Last post September 04, 2018
    • 
      
      
      
      
      
      INFO   : Image 1 selected (Core)...
      INFO   : Creating sparse disk...
      INFO   : Attaching VHDX...
      INFO   : Disk initialized with GPT...
      INFO   : Disk partitioned
      INFO   : System Partition created
      INFO   : Boot Partition created
      INFO   : System Volume formatted (with DiskPart)...
      INFO   : Boot Volume formatted (with Format-Volume)...
      INFO   : Access path (F:\) has been assigned to the System Volume...
      INFO   : Access path (G:\) has been assigned to the Boot Volume...
      INFO   : Applying image to VHDX. This could take a while...
      INFO   : Signing disk...
      INFO   : Image applied. Making image bootable...
      ERROR  : This command cannot be run due to the error: The system cannot find the file specified.
      INFO   : Log folder is C:\Users\NewUser\AppData\Local\Temp\Convert-WindowsImage\fd7fe739-61fc-4abb-acd1-bbcb7fbf43ef
      
      INFO   : Closing Windows image...
      INFO   : Closing VHDX...
      INFO   : Done.
      
      ANY IDEAS? THANKS
    • Hi Chawoja,
      
      Try to check if bcdedit.exe is accessible - the script uses it to make image bootable.
  • Problem on Windows 10 1709
    1 Posts | Last post May 03, 2018
    • I changed the script as per Cryptonym dec 06 2017 and still get this error
      Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
      Process ID: 2272
      PSVersion: 5.1.16299.251
      PSEdition: Desktop
      PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.16299.251
      BuildVersion: 10.0.16299.251
      CLRVersion: 4.0.30319.42000
      WSManStackVersion: 3.0
      PSRemotingProtocolVersion: 2.3
      SerializationVersion: 1.1.0.1
      **********************
      INFO   : Opening ISO WinPro1709.ISO...
      INFO   : Looking for E:\sources\install.wim...
      
      INFO   : Image 5 selected (Professional)...
      INFO   : Creating sparse disk...
      INFO   : Attaching VHD...
      INFO   : Disk initialized with GPT...
      INFO   : Disk partitioned
      INFO   : System Partition created
      INFO   : Boot Partition created
      INFO   : System Volume formatted (with DiskPart)...
      INFO   : Boot Volume formatted (with Format-Volume)...
      INFO   : Access path (\\?\Volume{dc0a76b5-f958-4bb4-974b-b39be5e62ca2}\) has been assigned to the System Volume...
      INFO   : Access path () has been assigned to the Boot Volume...
      INFO   : Applying image to VHD. This could take a while...
      PS>TerminatingError(ForEach-Object): "Exception calling "Apply" with "1" argument(s): "Value cannot be null.
      Parameter name: ApplyToPath""
      ERROR  : Exception calling "Apply" with "1" argument(s): "Value cannot be null.
      Parameter name: ApplyToPath"
      INFO   : Log folder is C:\Users\bobby\AppData\Local\Temp\Convert-WindowsImage\af2316fb-ffed-49c4-9cc8-8ca2a4f3c3ab
      
      INFO   : Closing Windows image...
      INFO   : Closing VHD...
      INFO   : Closing ISO...
      INFO   : Done.
  • Need Steps- How do I create a Windows 10 Image as .vhdx and use that as a boot option on another Windows 10 machine
    1 Posts | Last post April 10, 2018
    • I wish to take an image backup as .vhdx from one of my Windows 10 machines, and then use that .vhdx (either as bootup (preferred) or in Hyper-V") to start using that as my image from this heavy demo machine.
      
      Please suggest!
      Tara
  • wmi with single edition
    1 Posts | Last post February 13, 2018
    • In my wmi, there is only one image, and ImageFlags is null. So, the powershell was failing when assigning ImageFlags to $Edition. I amended the code (near line 4073):
                      # If there's only one image in the WIM, just select that.
                      if ($openWim.Images.Count -eq 1) { 
                          if ([String]::IsNullOrEmpty($openWim.Images[0].ImageFlags)) {
                              $Edition   = $openWim.Images[0].ImageName 
                          } else {
                              $Edition   = $openWim.Images[0].ImageFlags
                          }
                          $openImage = $openWim[$Edition]
                      } else { ...
      
      hope this helps... great tool by the way, saved me a ton of time.
  • Error with Windows 7 image
    4 Posts | Last post February 05, 2018
    • I'm getting an error when I try to process a Windows 7 Professional image:
      VERBOSE: isUserAdmin? True
      VERBOSE: is Windows 8 or Higher? True
      VERBOSE: Temporary VHD path is : c:\downloads\e3b150e3-17aa-4c45-bd83-8fe76e062618.vhd
      INFO   : Opening ISO en_windows_7_professional_x86_dvd_x15-65804.iso...
      INFO   : Looking for E:\sources\install.wim...
      INFO   : Image  selected ()...
      
      PS>TerminatingError(): "Convert-WindowsImage only supports Windows 7 and Windows 8 WIM files.  The specified image does not appear to contain one of those operating systems."
      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\DPCADM~1.TES\AppData\Local\Temp\3\Convert-WindowsImage\e3b150e3-17aa-4c45-bd83-8fe76e062618
      INFO   : Closing Windows image...
      INFO   : Closing ISO...
    • OK, sorted this issue. Script started working
    • How did you solve it? I have the same question?
    • Seems to be the -RemoteDesktopEnable switch only works on Win7/8 WIM images.
  • Failure when Attempting WSE deployment
    4 Posts | Last post January 22, 2018
    • Downloaded to c:\scripts folder, unblocked, ran the recommended command from admin command shell specified https://msdn.microsoft.com/en-us/library/windows/hardware/dn898458(v=vs.85).aspx.
      
      powershell -c "Set-ExecutionPolicy Unrestricted; C:\scripts\Convert-WindowsImage.ps1 -VHDFormat vhdx -sizebytes 127GB –sourcepath C:\OEMEssentials.iso -vhdpath C:\OEMEssentials.vhdx"
      
      Nothing happens. No error. No messages at all. Just returns to C: prompt.
      
      Open admin powershell and tried:
      
      Set-ExecutionPolicy Unrestricted; C:\scripts\Convert-WindowsImage.ps1 -VHDFormat vhdx -sizebytes 127GB –sourcepath C:\OEMEssentials.iso -vhdpath C:\OEMEssentials.vhdx
      
      Prompt for execution policy. Pressed Y and ether. Then nothing happens. No error. No messages at all. Just returns to the PS prompt.
      
      I don't understand what is wrong.
    • Convert-WindowsImage has been created as a function hence these are the commands that you would need to run.
      
      Set-ExecutionPolicy Unrestricted
      .'C:\scripts\Convert-WindowsImage.ps1'
      Convert-WindowsImage -VHDFormat vhdx -sizebytes 127GB –sourcepath C:\OEMEssentials.iso -vhdpath C:\OEMEssentials.vhdx
      
      You might need to add the "-Edition" and "-DiskLayout" to the last command.
      
    • Mjmeans could answer me, if I could solve the problem, I'm having the same problem as you.
    • This is what I had to use.  
      . ./Convert-WindowsImage
      Convert-WindowsImage -VHDFormat vhdx -sizebytes 127GB –sourcepath I:\sou
      rces\install.wim -Edition ServerDatacenter -vhdpath C:\VHDs\win2012r2trm.vhdx.  And it worked like a charm.  your source paths and vdhpaths will be different of couse.
  • Issues Running the script
    5 Posts | Last post January 21, 2018
    • when i run this below:
      .\Convert-WindowsImage.ps1 -SourcePath D:\OS's\ISO\WindowsServer2016.iso -VHDFormat VHDX -Edition Standard -VHDPartitionStyle GPT
      
      it does nothing. do not get an error or failure. Just moves on to the next line
      
      where would i see errors for this? 
      
      
      
    • it's a cmdlet now
    • what I have to do to resolve this? Same problem.
    • Load it first with dot dot slash. ie: . .\Convert-WindowsImage 
      then Convert-WindowsImage ...blah blah
    • First I downloaded the script and changed the lines suggested by Cryptonym (from Dec 6. 2017). Notice the one he missed as well and I changed line 4205 - not 4207 as he suggests.
      
      What I did was to convert a Win10 1709 Education customized install.WIM to VHDX was this:
      1. Open Powershell as administrator
      2. Set-ExecutionPolicy Unrestricted and answer A for Yes To All.
      3. Go to the folder you have the script.
      3. Type: . .\Convert-WindowsImage.ps1 (That's dot-space-dot-backslash at the start there)
      4. Type:
      Convert-WindowsImage -SourcePath C:\dev\1709\sources\install.wim -Edition Education -WorkingDirectory d:\VHDs
  • .wim with no SKU
    1 Posts | Last post December 22, 2017
    • How about captured wim which does NOT have any SKU>
      
       get UI window but when i select wim file 
      
      I get the error below:
      
      
      Unhandled exception has occurred in a comparison in your application. If you click Continue, the application will ignore this error and attempt to continue. UNABLE to load WIM metadata! 
      I CLICK ON CONTINUE 
      - I don't have anything in SKU list drop box
      I leave VHD DYNAMIC 40 GB ...and chose D: as working Directory and put Test.vhd name on VHD name. and click on " Make my VHD" then 
      i get error below:
      
      
      ERROR  : The variable cannot be validated because the value  is not a valid value for the Edition variable.
      
      Seb
  • Is there a workaround for Win 10 1709 (Fall Creators)
    1 Posts | Last post November 09, 2017
    • As noted by Phil Bolduc, 1709 breaks this script.  Is anyone aware of a workaround or replacement? 
11 - 20 of 154 Items