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,303 times
Add to favorites
Storage
6/19/2015
E-mail Twitter del.icio.us Digg Facebook
  • convert-windowsimage.ps1 -Edition variable
    1 Posts | Last post April 30, 2013
    • Hi I'm getting the following error:
      
      -----------------------------------------------------------------------------------------------
      PS> e:\convert-windowsimage.ps1 -SourcePath g:\pc20a.wim
      
      ERROR  : The variable cannot be validated because the value  is not a valid value for the Edition variable.
      ----------------------------------------------------------------------------------
      I have tried specifying the edition.. 
      There is only one edition in the wim.. 
       - Its a capture of a pc build (with imagex).. 
      Imagex restored the wim to a mounted vhd fine.. 
      However i would have preferred the ease of the script as the vhd route is a pain needing the boot sector re-writing and the volume setting as active.. 
      
      I'm sure it's just me missing something simple.
      Thanks in advance
      
      David (Nobby) Barnes
      
      
  • Cannot bind argument to parameter 'Path' Error
    8 Posts | Last post April 29, 2013
    • Hi,
      
      I am getting the following error when I try to use the script:
      
      System.Management.Automation.ParameterBindingValidationException: Cannot bind argument to parameter 'Path' because it is null
      
      Any ideas how to resolve it?
      
      Thanks,
      Kevin.
    • Without more information, no.  Can you post the command line that you're using?
    • I was just trying to use the GUI.  Can I email you the error dump and a screenshot?
    • Yes, please do.  Also, from your PowerShell session, please send me the contents of the $error variable immediately after Convert-WindowsImage.ps1 fails.  (For best results, please run $Error.Clear() immediately *before* running Convert-WindowsImage.ps1).  Hopefully, it'll help me narrow down where the issue is.  You can reach me at mikekol at Microsoft dot com.
    • Hi Exodic Hadron,
      
      did you execute the procedure sugested by Mike?
      
      Thank you.
    • Does it work on Windows Server 2012?
    • Sorry, ignore my last post. I posted it at wrong place.
    • Same issue here. GUI is ignoring selected path via ... dialog and it is showing previous path (initial path where script was running). After running script it failed. 
      
      Also - there is one more thing - ISO was not dismounted!
  • Getting an error after the first time a VHD is created
    2 Posts | Last post March 15, 2013
    • I was able to successfully run the script to create a VHD with an injected image.  After the initial VHD creation no further VHDs can be created.  When running the script the output of a failure looks like this.
      
      $OSDRIVE = .\Convert-WindowsImage.ps1 -SourcePath .\HyperV-2008R2-x64.wim -Edition 1 -passthru
      
      Windows(R) Image to Virtual Hard Disk Converter for Windows(R) 8
      Copyright (C) Microsoft Corporation.  All rights reserved.
      Version 6.2.8424.1.amd64fre.fbl_core1_hyp_dev(mikekol).120517-1616 Release Preview
      
      INFO   : Image 1 selected ()...
      INFO   : Creating sparse disk...
      INFO   : Attaching VHD...
      INFO   : Disk initialized...
      INFO   : Disk partitioned...
      INFO   : Volume formatted...
      INFO   : Access path (F:\) has been assigned...
      INFO   : Applying image to VHD.  This could take a while...
      INFO   : Signing disk...
      Join-Path : Cannot find drive. A drive with the name 'F' does not exist.
      At D:\workclutter\Hyper-V\Convert-WindowsImage.ps1:4049 char:41
      +         $flagText | Out-File -FilePath (Join-Path $drive "Convert-WindowsImageIn ...
      +                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : ObjectNotFound: (F:String) [Join-Path], DriveNotFoundException
          + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.JoinPathCommand
      
      ERROR  : Cannot bind argument to parameter 'FilePath' because it is null.
      INFO   : Log folder is C:\Users\ADMINI~1\AppData\Local\Temp\2\Convert-WindowsImage\95605006-1d8a-46da-a2dd-a39d1235ddb9
      INFO   : Closing Windows image...
      INFO   : Closing VHD...
      INFO   : Done.
      
      
      I have attempted to troubleshoot and found that the vds had stopped during the image, I started it but the process still failed.
      During the image I can do a psdrive and see the F: drive listed.
      
    • I resolved my own issue.  This was due to not enough hard drive space available to fully provision the VHD.
  • Unable to load WIM metadata
    2 Posts | Last post December 14, 2012
    • Hello,
      I'm experiencing the same error that Exotic Hadron is reporting - ConvertWindowsImage.ps1 is failing to convert a perfectly fine WIM (created by ImageX)into VHD as it's complaining about being "unable to load WIM metadata".
      Would really appreciate if this issue could be resolved.  Please let me know if there's any other helpful information I can provide.
      
      Thanks,
      Jeff
      
      PS C:\temp\WIM2VHD> $error
      Form session has been cancelled.
      At C:\temp\WIM2VHD\Convert-WindowsImage.ps1:3831 char:17
      +                 throw "Form session has been cancelled."
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : OperationStopped: (Form session has been cancelled.:String) [], RuntimeException
          + FullyQualifiedErrorId : Form session has been cancelled.
      
      Unable to load WIM metadata!
      At C:\temp\WIM2VHD\Convert-WindowsImage.ps1:3345 char:25
      +                         throw "Unable to load WIM metadata!"
      +                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : OperationStopped: (Unable to load WIM metadata!:String) [], RuntimeException
          + FullyQualifiedErrorId : Unable to load WIM metadata!
      
      Exception calling "Add" with "1" argument(s): "Value cannot be null.
      Parameter name: item"
      At C:\temp\WIM2VHD\Convert-WindowsImage.ps1:3339 char:54
      +                             $tempOpenWim.Images | %{ $cmbSkuList.Items.Add($_.Im ...
      +                                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
          + FullyQualifiedErrorId : ArgumentNullException
    • Here's the output from an imagex /info query of the WIM I'm trying to convert.
      -Jeff
      
      c:\WIM\ImageX>imagex /info C:\Images\WIM\W2K8R2-amd64-121117.wim
      
      ImageX Tool for Windows
      Copyright (C) Microsoft Corp. All rights reserved.
      
      
      
      WIM Information:
      ----------------
      GUID:        {ba9ead83-0721-4279-84bc-cb7acb3b2121}
      Image Count: 1
      Compression: XPRESS
      Part Number: 1/1
      Attributes:  0x8
                   Relative path junction
      
      
      Available Image Choices:
      ------------------------
      <WIM>
        <TOTALBYTES>6079283548</TOTALBYTES>
        <IMAGE INDEX="1">
          <DIRCOUNT>26101</DIRCOUNT>
          <FILECOUNT>85367</FILECOUNT>
          <TOTALBYTES>18075673830</TOTALBYTES>
          <HARDLINKBYTES>3926317169</HARDLINKBYTES>
          <CREATIONTIME>
            <HIGHPART>0x01CDC51A</HIGHPART>
            <LOWPART>0xF6B522A0</LOWPART>
          </CREATIONTIME>
          <LASTMODIFICATIONTIME>
            <HIGHPART>0x01CDDA3F</HIGHPART>
            <LOWPART>0xBCB9B1C8</LOWPART>
          </LASTMODIFICATIONTIME>
          <WINDOWS>
            <ARCH>9</ARCH>
            <PRODUCTNAME>Microsoft« Windows« Operating System</PRODUCTNAME>
            <EDITIONID>ServerEnterprise</EDITIONID>
            <INSTALLATIONTYPE>Server</INSTALLATIONTYPE>
            <HAL>acpiapic</HAL>
            <PRODUCTTYPE>ServerNT</PRODUCTTYPE>
            <PRODUCTSUITE>Enterprise</PRODUCTSUITE>
            <LANGUAGES>
              <LANGUAGE>en-US</LANGUAGE>
              <DEFAULT>en-US</DEFAULT>
            </LANGUAGES>
            <VERSION>
              <MAJOR>6</MAJOR>
              <MINOR>1</MINOR>
              <BUILD>7600</BUILD>
              <SPBUILD>16850</SPBUILD>
              <SPLEVEL>0</SPLEVEL>
            </VERSION>
            <SYSTEMROOT>WINDOWS</SYSTEMROOT>
          </WINDOWS>
          <NAME>W2K8R2 amd64 ImageX created on 121117 by img.creator</NAME>
        </IMAGE>
      </WIM>
      
      
  • Error Reading Metadata when ImageX Reads it Well
    4 Posts | Last post December 06, 2012
    • Hello again,
      
      Here's the output of ImageX for reading WIM metadata. The WIM2VHD fails to read it. What could be the problem?
      
      C:\Program Files\Windows AIK\Tools\amd64>imagex /info d:\install.wim
      
      ImageX Tool for Windows
      Copyright (C) Microsoft Corp. All rights reserved.
      Version: 6.1.7600.16385
      
      WIM Information:
      ----------------
      Path:        d:\install.wim
      GUID:        {73xxxxxx-5e95-4278-aa16-xxxxx1eb53cd}
      Image Count: 1
      Compression: XPRESS
      Part Number: 1/1
      Boot Index:  1
      Attributes:  0xc
                   Integrity info
                   Relative path junction
      
      
      Available Image Choices:
      ------------------------
      <WIM>
        <TOTALBYTES>66078907319</TOTALBYTES>
        <IMAGE INDEX="1">
          <DIRCOUNT>56953</DIRCOUNT>
          <FILECOUNT>398988</FILECOUNT>
          <TOTALBYTES>132050267064</TOTALBYTES>
          <HARDLINKBYTES>5323610509</HARDLINKBYTES>
          <CREATIONTIME>
            <HIGHPART>0x01CD5DF2</HIGHPART>
            <LOWPART>0xCFE25D49</LOWPART>
          </CREATIONTIME>
          <LASTMODIFICATIONTIME>
            <HIGHPART>0x01CD5DF2</HIGHPART>
            <LOWPART>0xD326C12C</LOWPART>
          </LASTMODIFICATIONTIME>
          <WINDOWS>
            <ARCH>9</ARCH>
            <PRODUCTNAME>MicrosoftR WindowsR Operating System</PRODUCTNAME>
            <EDITIONID>ServerDatacenter</EDITIONID>
            <INSTALLATIONTYPE>Server</INSTALLATIONTYPE>
            <HAL>acpiapic</HAL>
            <PRODUCTTYPE>ServerNT</PRODUCTTYPE>
            <PRODUCTSUITE>Terminal Server</PRODUCTSUITE>
            <LANGUAGES>
              <LANGUAGE>en-US</LANGUAGE>
              <DEFAULT>en-US</DEFAULT>
            </LANGUAGES>
            <VERSION>
              <MAJOR>6</MAJOR>
              <MINOR>1</MINOR>
              <BUILD>7601</BUILD>
              <SPBUILD>17651</SPBUILD>
              <SPLEVEL>1</SPLEVEL>
            </VERSION>
            <SYSTEMROOT>WINDOWS</SYSTEMROOT>
          </WINDOWS>
          <NAME>Windows Server 2008 R2</NAME>
        </IMAGE>
      </WIM>
    • Hi Hadron,
      It looks like there's a problem while opening the WIM file.  Can you do the following things for me please?
      1) Open an elevated PowerShell prompt.
      2) Run "$error.clear()" (without the quotes)
      3) Run Convert-WindowsImage as you normally would.  
      4) After Convert-WindowsImage errors out, run "$error", copy the output, and paste the text in a new question here.  
      
      That should help me figure out what's going wrong and where.
      
      Thanks!
      mk
    • Hi Exodic Hadron,
      
      did you execute the procedure sugested by Mike?
      
      Thank you.
    • Hi Caio Vilas Boas,
      Sure, you may find error output below, I copy it here:
      
      PS C:\Users\EH\Downloads> $Error
      Form session has been cancelled.
      At C:\Users\EH\Downloads\Convert-WindowsImage.ps1:3831 char:17
      +                 throw "Form session has been cancelled."
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : OperationStopped: (Form session has been cancelled.:String) [], RuntimeException
          + FullyQualifiedErrorId : Form session has been cancelled.
       
      Unable to load WIM metadata!
      At C:\Users\EH\Downloads\Convert-WindowsImage.ps1:3345 char:25
      +                         throw "Unable to load WIM metadata!"
      +                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : OperationStopped: (Unable to load WIM metadata!:String) [], RuntimeException
          + FullyQualifiedErrorId : Unable to load WIM metadata!
  • Does it work on Windows Server 2012?
    1 Posts | Last post December 06, 2012
    • Does it work on Windows Server 2012?
  • Failed Convert WIM to VHD/VHDX on the EFI system
    2 Posts | Last post December 06, 2012
    • When Windows 8/Windows Server 2012 system is using EFI boot, this script will fail.
      The root cause is the bcdboot options.
      If you want to convert on the EFI system, you need to modify this script to add a bcdboot option "/f ALL" at the $bcdBootArgs.
      
    • That's correct.
  • Supress script output
    2 Posts | Last post December 06, 2012
    • Is it possible to supress script's output when executed from command line? I need to call it from VB.NET code.
    • Ola Gale,
      
      You can modify the code by adding this line: Proc.StartInfo.CreateNoWindow = true
  • Error Transcript for the Failed WIM Metadata Reading Operation. Part One
    1 Posts | Last post July 11, 2012
    • Hi, Mike!
      Thank you for your swift response!
      
      Here you go with the error output:
      
      ---BEGIN---
      
      PS C:\Users\EH\Downloads> .\Convert-WindowsImage.ps1 -ShowUI
      
      Windows(R) Image to Virtual Hard Disk Converter for Windows(R) 8
      Copyright (C) Microsoft Corporation.  All rights reserved.
      Version 6.2.8424.1.amd64fre.fbl_core1_hyp_dev(mikekol).120517-1616 Release Preview
      
      WARN   : Transcription is already running.  No Convert-WindowsImage-specific transcript will be created.
      INFO   : Launching UI...
      INFO   : Scanning WIM metadata...
      ERROR  : Form session has been cancelled.
      INFO   : Log folder is C:\Users\EH\AppData\Local\Temp\Convert-WindowsImage\0d4c9575-f89d-4c2b-ac12-60328911b68c
      INFO   : Done.
      
      PS C:\Users\EH\Downloads> $Error
      Form session has been cancelled.
      At C:\Users\EH\Downloads\Convert-WindowsImage.ps1:3831 char:17
      +                 throw "Form session has been cancelled."
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : OperationStopped: (Form session has been cancelled.:String) [], RuntimeException
          + FullyQualifiedErrorId : Form session has been cancelled.
       
      Unable to load WIM metadata!
      At C:\Users\EH\Downloads\Convert-WindowsImage.ps1:3345 char:25
      +                         throw "Unable to load WIM metadata!"
      +                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : OperationStopped: (Unable to load WIM metadata!:String) [], RuntimeException
          + FullyQualifiedErrorId : Unable to load WIM metadata!
  • The Script is Unable to Load WIM Metadata. Problem Reading SKU
    1 Posts | Last post July 10, 2012
    • Hello, Mike!
      
      I'm getting problem loading WIM metadata:
      
      ************** Exception Text **************
      System.Management.Automation.RuntimeException: Unable to load WIM metadata! ---> System.Management.Automation.RuntimeException: Unable to load WIM metadata!
         --- End of inner exception stack trace ---
         at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
      
      The WIM contains Windows Server 2008 R2 image.
      
      I am running the script using the -showui switch.
      
      The WIM has been created using the following command:
      
      C:\Program Files\Windows AIK\Tools\amd64>imagex.exe /compress fast /check /boot
      /capture s: d:\install.wim "Windows Server 2008 R2"
      
      What could be the problem? What metadata is being searched?
      
      Thank you.
141 - 150 of 154 Items