Powershell script to convert VHD to WIM file

Here is a simple script to convert VHD file to WIM file

#set the VHD mount folder
$Mount="c:\mount"
#create a folder c:\mount
Mkdir $Mount

#mount the c:\temp\spiderip.vhd to $Mount folder

Mount-WindowsImage -ImagePath "c:\temp\spiderip.vhd" -Path "$Mount" -Index 1
#Create new Wim image to c:\temp\spiderip.wim folder

New-WindowsImage -CapturePath "$Mount" -Name "spiderip image" -ImagePath "c:\temp\spiderip.wim" -Description "spiderip image" -Verify
#dismount  the $Mount folder
Dismount-WindowsImage -Path "$Mount" -Discard

Comments