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)
142,265 times
Add to favorites
Storage
6/19/2015
E-mail Twitter del.icio.us Digg Facebook
  • Error when using on Win 10 release media created using Media Creation Tool
    2 Posts | Last post August 02, 2015
    • Using either v10 or v6.3 with any of the media I have created using the Wndows 10 media creation tool (from http://www.microsoft.com/en-us/software-download/windows10) I can't seem to always get the following - seemingly regardless of VHD creation options chosen..
      
      Windows(R) Image to Virtual Hard Disk Converter for Windows(R) 8
      Copyright (C) Microsoft Corporation.  All rights reserved.
      Version 6.3.9600.7.amd64fre.fbl_core1_hyp_dev(mikekol).140217-3000 Release to Web
      
      ERROR  : Exception calling ".ctor" with "1" argument(s): "An attempt was made to load a program with an incorrect format"
      
      Same command line works with Insider Preview build 10240 ISO that I have.
      
      Any else struggling with this?
      
      Dave
    • OK, got different media that includes Home and Pro versions, script now appears to be running OK.  Suspect problem is that only 1 version was contained within install.wim on the media that I had created using the Media Creation Tool
      
      Dave
  • \Convert-WindowsImage.ps1 -ShowUI
    1 Posts | Last post July 20, 2015
  • Show UI
    2 Posts | Last post July 18, 2015
    • .\Convert-WindowsImage.ps1 -ShowUI
      
      Running this command in ISE, I'm not sure how you call the function in the code. Could someone copy pasta me the snippet of where this command is meant to sit in the code?
      
      Currently it does nothing when I run the code, even when I use ShowUI nothing happens. 
      Thanks
    • Worked it out, it was the function at the start it would run if that was in the code. 
  • Unable to resolve an error with GPT partitioning.
    2 Posts | Last post July 16, 2015
    • Hello, please help. turned this nice function into a module but get an error with -VHDPartitionStyle GPT.
      
      I get this error:
      INFO   : Image 4 selected (ServerDataCenter)...
      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 (H:\) has been assigned to the System Volume...
      INFO   : Access path (J:\) has been assigned to the Boot Volume...
      INFO   : Applying image to VHDX. This could take a while...
      INFO   : Signing disk...
      Join-Path : Cannot find drive. A drive with the name 'J' does not exist.
      At C:\Users\Administrator\Documents\WindowsPowerShell\Modules\Convert2VHDX\Conv
      ert2VHDX.psm1:4244 char:53
      + ... le -FilePath (Join-Path $drive "Convert-WindowsImageInfo.txt") -Encod ...
      +                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : ObjectNotFound: (J:String) [Join-Path], DriveNot 
         FoundException
          + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.Join 
         PathCommand
       
      ERROR  : Cannot bind argument to parameter 'FilePath' because it is null.
      INFO   : Log folder is C:\Users\ADMINI~1\AppData\Local\Temp\Convert-WindowsImage
      \60cc9886-58aa-4262-94cb-29693cea77ae
      
      INFO   : Closing Windows image...
      INFO   : Closing VHDX...
      INFO   : Closing ISO...
      INFO   : Done.
    • I used this parameters in my command.
      
      Convert-WindowsImage -SourcePath 'D:\ISOz\KORISNO\WS2k12_R2_Standard_&_Datacenter_Edition.iso' `
                           -Edition 4 `
                           -VHDPath 'D:\Downloads\W2k12R2_Datacenter_GUI.vhdx' `
                           -VHDFormat VHDX `
                           -VHDType Dynamic `
                           -VHDPartitionStyle GPT `
                           -Package 'D:\Updates_W81_WS2k12\' `
                           -Verbose
      
      Any help would be greatly appreciated.
      
      Thanks to the creator of the script.
  • Error converting String[] to Int32
    3 Posts | Last post July 15, 2015
    • I have been trying to convert Windows NanoServer wim to vhd and keep getting error about converting String[] to Int32. When I try the same with ShowUI, there is an error about Path being null or empty when wim is selected.
      
      Convert-WindowsImage –WIM .\NanoServer.wim –VHD .\NanoServer.vhdx –Edition 1
      
      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
      
      ERROR  : Cannot convert the "System.String[]" value of type "System.String[]" to type "System.Int32".
      INFO   : Log folder is C:\Users\User\AppData\Local\Temp\Convert-WindowsImage\c2097b0a-b80d-4a5c-98d2-89e8e5af296d
      
      INFO   : Closing Windows image...
      INFO   : Done.
    • Microsoft, please help.  I too am getting this:
      
      "ERROR  : Cannot convert the "System.String[]" value of type "System.String[]" to type "System.Int32"."  
      
      I think it's in response to the param "-Edition 1".  
      
      When I try to launch from the GUI, the "Choose a SKU from the list" combobox is not populated with any values.
      
      The command I am trying to run is:
      Convert-WindowsImage –WIM e:\nanoserver\nanoserver.wim –VHD c:\vhd\nanoserver.vhd -VHDFormat VHD –Edition 1
      
      I am running this on Windows Server 2012 (not R2).
    • I found the answer lower in this comment thread.
      
      Change line 4092 of the script to this:
      $openImage = $openWim[[Int32]::Parse($Edition)]
  • Mount-DiskImage : The parameter is incorrect.
    1 Posts | Last post July 12, 2015
    • Hey Guys,
      
      I tried multiple times running this script on Windows 2016 and it failed with below error. 
      
      Mount-DiskImage : The parameter is incorrect. 
      At C:\Software\Windows\Convert-WindowsImage.ps1:3404 char:48
      + ... enIso     = Mount-DiskImage -ImagePath $isoPath -StorageType ISO -Pas ...
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidArgument: (MSFT_DiskImage:ROOT/Microsoft/.../MSFT_DiskImage) [Mount-DiskImage], CimException
          + FullyQualifiedErrorId : HRESULT 0x80070057,Mount-DiskImage
       
      Get-DiskImage : The parameter is incorrect. 
      At C:\Software\Windows\Convert-WindowsImage.ps1:3407 char:48
      + ...                      $openIso     = Get-DiskImage -ImagePath $isoPath
      +                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidArgument: (MSFT_DiskImage:ROOT/Microsoft/.../MSFT_DiskImage) [Get-DiskImage], CimException
          + FullyQualifiedErrorId : HRESULT 0x80070057,Get-DiskImage
      
      Seems like a bug, what I did to fix is as below.
      Login to a Windows 2012 R2 Server
      1) Open the script with Powershell ISE as admin
      2) As mentioned by Wesley De Arburn, Search for "$script:SourcePath" and replace it with "$SourcePath"
      3) Save the script 
      4) Minimize the function
      5) Add New line like below
      Convert-WindowsImage -SourcePath C:\software\windows\Threshold.ISO -VHDPath C:\Software\Threshold.vhdx -VHDFormat VHDX -VHDPartitionStyle GPT -Edition ServerStandard
      
      PS C:\Software\Windows> C:\Users\Administrator\Desktop\Convert-WindowsImage.ps1
      
      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 Threshold.ISO...
      INFO   : Looking for E:\sources\install.wim...
      
      INFO   : Image 2 selected (ServerStandard)...
      INFO   : Creati
  • I get the following error
    4 Posts | Last post July 09, 2015
    • Format-Volume : One or more parameter values passed to the method were invalid.
      En C:\Users\User\Downloads\Convert-WindowsImage.ps1: 4199 Carácter: 44
      +                         $volume          = Format-Volume -Partition $partition - ...
      +                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidArgument: (MSFT_Volume (Ob...2-a33e-5959...):ROOT/Microsoft/...age/MSFT_Volume) [Format-Volume], CimException
          + FullyQualifiedErrorId : MI RESULT 4,Format-Volume
    • Apparently an assigned drive letter is required for Format-Volume to work:
      
      $partition       = New-Partition -DiskNumber $openVhd.DiskIndex -UseMaximumSize -AssignDriveLetter -GptType '{ebd0a0a2-b9e5-4433-87c0-68b6b72699c7}'
      
      For some reason I do not need such previously assigned drive letter when running the script in other machines...
    • For some reason I get parameter incorrect errors also when trying to format newly created partitions with diskpart until I assign them a drive letter. The problem is definitely on my side as I was not able to reproduce this in other machines. Ignore my previous comments while I try to guess what caused this issue.
    • Apparently I had diskpart automount set as disabled. Anyway this script takes for granted the default setting for automount is enabled. If for some reason automount was disabled the script will always fail as neither diskpart nor the Format-volume cmdlet can format an offline volume. Without automount enabled new partitions will be created with offline RAW volumes that cannot be formatted until the are set on-line by the assignment of a drive letter.
  • Cannot boot and blue screen
    1 Posts | Last post July 08, 2015
    • That's strange. Managed to create a NanoServer vhd, but when I create a generation 1 VM cannot boot, when I create a generation 2 vhdx I get a bluescreen in Windows 10 Hyper-V. Any ideas?
  • Will not Run
    6 Posts | Last post July 03, 2015
    • Hello am I missing something I do in powershell prompt 
      
      .\Convert-WindowsImage.ps1 -ShowUI  it won't show anything  is they any way  troblueshoot it try sample in code and they don'nt even come back showing anything 
    • 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.
    • That works - add the line to the end of the script !
    • I have to recall ==> the change helped, but stil no success
      ERROR  : No source path specified.
      Gui is working and with replacement of the variable I can choose an ISO Image, but not able to convert
    • Open the script on notepad => Copy/Paste the script to PowerShell ISE => Execute it by pressing f5=> then run the Convert-windowsImage function (not PS1 itself)
      
      Detailed intructions found our blog:
      http://virtualstation.azurewebsites.net/?p=9551
    • I didn't believe that this works, but yes that was the solution. 
      Used original script with the explained workaround on 
      
      http://virtualstation.azurewebsites.net/?p=9551
      
      THANKS - I was working on that since a few weeks !
  • Getting error when trying to format
    1 Posts | Last post July 03, 2015
    • When running the command Convert-WindowsImage -SourcePath G:\install.wim -VHDFormat VHDX -Edition "ServerDataCenterCore" -SizeBytes 8GB -VHDPartitionStyle MBR -BCDinVHD NativeBoot -ExpandOnNativeBoot:$false -RemoteDesktopEnable
      
      I get the error Format-Volume : One or more parameter values passed to the method were invalid. I am using the install.wim from Server 2012 R2 with update. I also get a prompt on screen saying I need to format the disk in drive {Letter} before you can use it. Any idea what may be causing this?
81 - 90 of 154 Items