Windows: Create a Windows Server 2016 .wim image

Created: 12/14/19

Updated: 12/20/19

So in recent times I’ve been growing tired of having to spin up environments where I have multiple VM’s of all the same variation. I thought to myself; there has to be a better way.

So with the help of sysprep, a little F11 action, and DISM; you can create a pristine template with all of your desired applications, to-date Windows updates, and other settings and then perform a OOBE (generalization if you so choose too) and away you go.

Step 1: Install a Clean Windows Server 2016 installation

Step 2: perform Windows updates, reboots, yadda, yadda, yae!

Step 3: install any applications

Step 4: navigate to c:\%windows%\System32\sysprep and double click on sysprep

Step 5: press OOBE and select “generalize” if you want to reset the SID and press reboot

Step 6: upon reboot press F11 really quickly to bring up the boot menu, select the DVD where the install media is located and boot from it

Step 7: press next with the 1st page on the installer

Step 8: press the “repair this computer” selection

Step 9:  press “troubleshooting”

Step 10:  press “command prompt”

Step 11: 1st you gotta load diskpart

Step 12:  Then you gotta list the disks “list disk”

Step 13:  type the following: dism /capture-image /imagefile:c:\Server2016_Master_img.wim /capturedir:c:\ /name:”Windows Server 2016 Master Image”

Note: /imagefile let you know the name of the image file

/capturedir lets you specify the location where the file is stored

Note:  when you run this, it will take a little while to process the creation of the Windows Image File, might take about 20 minutes.

Step 14: now you gotta add a Ethernet adapter to the instance in command prompt you can copy the file off to a network share, so 1st up type: “start /w wpeinit” and press enter

Step 15: type the following for the network the server is attached to, in the following format:  netsh ip set address “Interface name” static <ip><netmask><gateway>

Step 16: type ipconfig and you should have an IP address

Step 17: ping the DF Gateway to see if your resolving correctly

Step 18: make a UNC mapping to a location where you can copy the .wim file too, like the following: net use h: \\x.x.x.x /user:administrator password

Step 19: type the following to copy the .wim file to the destination location of h:, like the following: copy c:\Server2016_Master_img.wim h:\

Whalla, you have just created a .wim file and uploaded it to a network share for future use. 🙂

Bonus: if you wanted the boot Windows Server 2016 for the .wim, then do the following, using the above logic:

Step 1: type diskpart

Step 2:  list vol

Step 3: type dism /apply-image /Imagefile:c:\Server2016_Master_img.wim /index:1 /applydir:c:\

/applydir is telling what partition you want it to be stored