How to Convert VHD to WIM File Using Native Windows Tools for SCCM Deployment


1 views

When preparing a sysprepped VM for SCCM deployment, you might encounter issues with PXE boot configurations. Some hypervisors like VMM stubbornly revert NIC settings despite showing "successful" changes. This forces us to find alternative image capture methods.

Windows Server 2012 R2 and later include built-in capabilities for VHD to WIM conversion without third-party tools. Here's the technical approach:

# Mount the VHD first
Mount-WindowsImage -Path "C:\mount" -ImagePath "C:\vm\sysprepped.vhd" -Index 1

# Export to WIM format
Export-WindowsImage -SourceImagePath "C:\mount" -SourceIndex 1 -DestinationImagePath "C:\images\captured.wim" -CompressionType max

For enterprise-sized VHDs, consider these optimizations:

# Split the WIM if needed (for files >4GB)
Dism /Export-Image /SourceImageFile:"C:\images\captured.wim" /SourceIndex:1 /DestinationImageFile:"C:\images\split.swm" /SplitImageFileSize:4096

# Verify the image after conversion
Dism /Get-WimInfo /WimFile:"C:\images\captured.wim"

For repeated deployments, create a PowerShell script:

$vhdPath = "C:\vms\production.vhd"
$wimPath = "C:\sccm_content\production.wim"
$mountPoint = "C:\mount_temp"

try {
    Mount-WindowsImage -Path $mountPoint -ImagePath $vhdPath -Index 1
    Export-WindowsImage -SourceImagePath $mountPoint -SourceIndex 1 -DestinationImagePath $wimPath
}
finally {
    Dismount-WindowsImage -Path $mountPoint -Discard
}

For older systems or when PowerShell isn't available:

Dism /Capture-Image /ImageFile:C:\images\captured.wim /CaptureDir:C:\mount /Name:"Production_Image" /Description:"Sysprepped VM Image"

After obtaining the WIM file, import it into SCCM:

  1. Navigate to Software Library > Operating Systems > Operating System Images
  2. Add the new WIM file
  3. Distribute to distribution points

When preparing a sysprepped VM for SCCM deployment, many administrators hit this roadblock: Hyper-V/VMM forcibly reverts NIC settings when attempting PXE boot configuration. The error persists even when the console claims successful changes. This leaves us needing alternative imaging methods.

Windows Server 2012 R2 includes all necessary components for direct conversion without third-party tools. The key utilities are:

# DiskPart for volume mounting
DISKPART> select vdisk file="C:\path\to\your.vhd"
DISKPART> attach vdisk
DISKPART> list volume
DISKPART> select volume X
DISKPART> assign letter=W

# Dism for image capture
dism /capture-image /imagefile:deployment.wim /capturedir:W:\ /name:"BaseImage"

Here's the complete workflow I've used in production environments:

  1. Shutdown the sysprepped VM completely
  2. Locate the VHD file (typically in Hyper-V's virtual hard disks folder)
  3. Run DiskPart as administrator to mount the VHD
  4. Note the assigned drive letter (W: in our example)
  5. Execute DISM capture command with appropriate parameters
  6. Verify the WIM contains all required volumes:
dism /get-wiminfo /wimfile:deployment.wim

For complex scenarios:

  • Multi-volume systems: Use /split-image when WIM exceeds 4GB
  • Index management: Append to existing WIMs with /append-image
  • Compression: Modify with /compress (max/fast/none)

Before importing to your SCCM server:

# Check architecture compatibility
dism /get-imageinfo /imagefile:deployment.wim /index:1 | findstr Architecture

# Verify drivers
dism /image:W:\ /get-drivers

This native approach eliminates dependency on PXE boot configurations and works reliably across Hyper-V generations.