1. Home
  2. IT Process Automation Tutorials
  3. IT Process Automation: silently re-image a Windows machine remotely with WDS

IT Process Automation: silently re-image a Windows machine remotely with WDS

In this tutorial we will demonstrate how to re-image a live Windows OS using a Goverlan Reach’s Process Automation framework and your WDS configuration.
Once this tutorial is complete, simply use the scope action or custom action to re-image any Windows machine.

Difficulty Level - Advanced

This scope action involves different Windows based technologies that are outside the scope of Goverlan. 


  • Live Windows OS – This method will only work against a Windows OS that is live and bootable to the desktop.
  • Windows Deployment Services Server – You will need a pre-existing WDS environment with pre-configured Boot & OS Images. (Getting Started with WDS)
  • Windows Assessment and Deployment Kit (Windows ADK) – You will need to have both the Deployment Tools (Deployment and Imaging Tools Environment) and the Windows Pre-installation Environment installed from the Kit. (Windows ADK)
  • Administrative access  to both the WDS environment and the machine you are re imaging.PLEASE NOTE: We HIGHLY recommend that you test this method in a lab (specifically a virtual machine with a revertible snapshot if possible) as you will be modifying the boot records and could render the machine un-bootable if any step in this article is over looked.

Preparing your environment

Preparing your environment will have 3 steps:

  1. Extracting the WinPE boot.wim image from your WDS deployment
  2. Configuring and injecting the AutoUnattend.xml file into the boot.wim
  3. Preparing the new WinPE directory structure

Deploying Images with Goverlan

Once the WinPE directory is ready, use a Goverlan Scope or Custom Action to copy the WinPE directory locally and then run the batch file to start the imaging process.

Step 1 – Extract WinPE Discovery Image from WDS

1. Extract the WinPE Discovery image from one of your OS boot images on your WDS server.

Simply right-click the boot image of the OS you want to deploy then click Create Discover ImageTHIS VIDEO will guide you through extracting the boot.wim needed for this method to work properly.


  • Take note of the boot image Architecture that you are creating this Discovery image from(see below image). Then save this as “boot.wim”, we will be using it down the line in this tutorial.
  • Make sure to add your WDS server name in the bottom section of the wizard titled “Enter the name of the Windows Deployment Services server….”

Step 2 – Create AutoUnattend.xml

Refer to the following TechNet article on Sample WDS Client Answer Files. You can simply copy paste the Sample xml on the technet site titled “Sample Windows Deployment Services client unattend file” as shown below.

  1. Modify this answer file with notepad and enter the appropriate settings/credentials according to your WDS setup.
  2. Save this file as AutoUnattend.xml.
  3. After creating the AutoUnattend.xml, store it in a safe place as we will need it for the next step.


In the AutoUnattend.xml, there will be some lines that end with processorArchitecture=”x86.” Change this according to the architecture of the Discovery image that was extracted in Step 1. If this does not match the architecture of the discovery image, the automated image will fail causing you to manually go to the machine and go through the Windows Setup prompts.

Step 3 – Insert AutoUnattend.xml into WinPE Discovery Image

1. Use the DISM command to mount the boot.wim image created in Step 1.

Refer to the following TechNet article on Modifying a WIM Image Using DISM via the Mounting an Image Section.

After mounting the boot.wim that was created in Step 1, you will see the following in your Mount Directory:

2. Simply copy paste the autounattend.xml file into this directory. The result will be the following:

3. Unmount the image with the /commit switch as mentioned in the section titled Unmounting an Image in the TechNet article above.

4. Store this modified boot.wim file as we will be using it in the next step.

Step 4 – Create WinPE Directory(x86 or x64)

1. On the machine that has the Windows ADK, go to All Programs > Windows Kits > Windows ADK and right-click Deployment and Imaging Tools Environment and select Run as Administrator. 

2. Now we will run one of the below commands based on the Architecture type of the OS you are going to push to your machines:

-For AMD64(64-bit) images: copype amd64 C:\WinPE

-For x86(32-bit) images: copype x86 C:\WinPE

After the command is completed your C:\WinPE directory will look as follows:

3. Delete the folders titled fwfiles mount.

4. Now inside of the folder called media you will see the below folders:

5. Select all the files and folders in C:\WinPE\media and cut them. Then paste them into C:\WinPE, one level above.
6. Delete the, now empty media folder. Your final C:\WinPE folder should look like the below:

Step 5 – Copy boot.wim to WinPE\Sources Directory

Finally, you will now copy the boot.wim created in Step 1 into the C:\WinPE\Sources directory. There will be another file with the same name inside of it, simply overwrite/delete this file.

Step 6 – Create the Scope Action

1. Please refer to the video below on how to create a scope action. If you are familiar with scope actions, proceed to the next step. Also see Scope Action Creation Basics article for more information.

2. Add any machines that will be re-imaged to your scope module.

Action Module #1: Copy WinPE Directory to Target Machine

Add/Remove > Execute Computer Action > File and Directory Actions > Transfer a Directory

Source Directory Local Path: C:\WinPE
Destination Directory Local Path: C:\WinPE
Overwrite Existing File: True
Include Sub-Directories: True

Action Module #2: Run Boot to PE Script

Open notepad and paste the following script code into it, then save the file as BootToWinPE.bat:

bcdedit.exe /create {ramdiskoptions} /d "Ramdisk options"
bcdedit.exe /set {ramdiskoptions} ramdisksdidevice partition=c:
bcdedit.exe /set {ramdiskoptions} ramdisksdipath \WinPE\boot\boot.sdi
for /f "tokens=2 delims={}" %%g in  ('bcdedit.exe /create /d "WINPE" /application OSLOADER') do (set guid={%%g})
echo %guid%
bcdedit.exe /set %guid% device ramdisk=[c:]\WinPE\sources\boot.wim,{ramdiskoptions}
bcdedit.exe /set %guid% path \windows\system32\boot\winload.exe
bcdedit.exe /set %guid% osdevice ramdisk=[c:]\WinPE\sources\boot.wim,{ramdiskoptions}
bcdedit.exe /set %guid% systemroot \windows
bcdedit.exe /set %guid% winpe yes
bcdedit.exe /set %guid% detecthal yes
bcdedit.exe /displayorder %guid% -addlast
bcdedit.exe /bootsequence %guid% /addfirst
bcdedit.exe /timeout 0

shutdown /r -t 0

Now create the second Action Module:

Add/Remove > Execute Computer Action > Processes > Run a Script

Refer to the below screenshot for the specific Arguments:

Important: The Run As Type must be set to 2, and you must insert your domain or local administrator credentials for this script to run properly. Selecting a Run as Type other than 2 will result in a failure in running the batch. 

3. Your final Scope Action should look like the below:


After executing this scope action or custom action, Goverlan will copy the WinPE files to the local machine and use the Boot to WinPE script to configure the computer to boot to that WinPE directory on the next boot only.

If the AutoUnattend.xml was created successfully, WinPE will authenticate and choose the correct image file and begin the imaging process.

This Scope Action can now be re-used to re-image any Windows system.

Updated on October 18, 2018

Related Articles