22

I just setup and sysprepped a nice new VM, now I need to convert it to a wim real quick, to upload to my sccm server. For some reason, I can't change the VM properties to boot from a legacy nic for pxe, which is how I usually capture my images using sccm. VMM just changes the settings right back, even though it says successful.

Anyway, the first page of google was terrible for this, w/ the exception of a 3rd party .ps1 script on MS's website, but I'm using 2012r2, I should be able to do this natively, right?

3 Answers 3

31

Absolutely, let's post a prim and proper answer for Google. This is a simple 2 command Powershell execution, using the dism module. The dism can be copied to earlier versions of Windows, provided you have the appropriate version of the windows management framework.

First, mount the vhd using

Mount-WindowsImage -ImagePath C:\VHDs\BigHomies.vhdx -Path C:\VHDMount -Index 1

Then, capture it into a wim with

New-WindowsImage -CapturePath C:\VHDMount -Name Win7Image -ImagePath C:\CapturedWIMs\Win7.wim -Description "Yet another Windows 7 Image" -Verify

And let it do it's thing. When you are done you can unmount the vhd and discard any changes using:

Dismount-WindowsImage -Path C:\VHDMount -Discard
8
  • 1
    Correction to the second command: -ImagePath should specify the full path to the WIM file (e.g. C:\CapturedWIMs\NewWinImage.wim), while -Name is the name of the image inside the WIM file (e.g. NewWinImage, but has no actual relation to the WIM file name). Executing the originally posted command results in "New-WindowsImage: Access is denied." (presumably because the command attempts to treat the C:\CapturedWIMs directory as a file). Oct 1, 2014 at 22:34
  • Interesting analysis, technet's example also seems to agree with you. I'll update it, even though I ripped this straight from my powershell prompt lol.
    – MDMoore313
    Oct 3, 2014 at 12:20
  • 1
    +1 this answer really helped me out! Jul 20, 2015 at 17:45
  • 1
    @ClearBoth on the New-WindowsImage command? I wonder if the vhdx is in use, or otherwise cannot be locked.
    – MDMoore313
    Jun 5, 2017 at 15:43
  • 1
    I know this answer is a few years old, but as far as I can tell, the process hasn't changed much... however I have had an issue with the above I felt it was useful to share, as I couldn't find google hits for the issue. Doing the above works fine, but I've had an issue where the c: drive permissions on a machine built with SCCM matched the permissions of the folder you've used to mount the image, rather than the permissions the VHDX had originally. The solution seems to be to mount the vhdx to a drive, instead of in a folder.
    – Stese
    Jul 7, 2023 at 7:25
3

If, for some reason, Powershell is not an option - do not despair!

In Windows 7 or later, you can mount the .vhd via disk management (link)

Once it is mounted, you can use imagex.exe to capture the .wim (technet link)

0

Same method as the accepted answer, but without the need for PowerShell

dism /Mount-Image /ImageFile:C:\Backup.vhdx /Index:1 /MountDir:C:\Mount
dism /Capture-Image /ImageFile:C:\Backup.wim /CaptureDir:C:\Mount /Name:Backup
Dism /Unmount-Image /MountDir:C:\Mount /Discard

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .