My name is Jitesh Kumar and I have more than 3 years experience in IT Domain, having expertise on Windows 10 deployment, including the various microsoft tools (ConfigMgr ,MDT) and deployment solutions. I’ll have more posts in the future. In this post, you will learn details about running sysprep capture Windows 10 Image using DISM (Deployment Image Servicing and Management) Tool.
DISM is command line tool can be used to prepare a Windows Image. More detailed info about DISM from Microsoft Blog.
Why Use DISM -In most of the organizations Windows Image deployments is preferred through Microsoft Deployment Tools [SCCM, MDT]. But, due to applied policies in environment several times we are not getting permitted to run the capture Task Sequences.
What is SysPrep?
Sysprep (System Preparation) prepares a Windows installation (Windows client and Windows Server) for imaging, allowing you to capture a customized installation. Sysprep removes PC-specific information from a Windows installation, “generalizing” the installation so it can be installed on different PCs.
With Sysprep you can configure the PC to boot to audit mode, where you can make additional changes or updates to your image. Or, you can configure Windows to boot to the Out-of-Box Experience (OOBE).
Benefits of using Sysprep
- Removes system-specific data from Windows. Sysprep can remove all system-specific information from an installed Windows image, including the computer security identifier (SID). The Windows installation can then be captured and installed throughout an organization.
- Configures Windows to boot to Audit mode. Audit mode enables you to install third-party applications and device drivers, as well as to test the functionality of the computer.
- Configures Windows to boot to Windows Welcome. Configures a Windows installation to boot to Windows Welcome the next time the computer starts. In general, you configure a system to boot to Windows Welcome immediately before delivering the computer to a customer.
- Resets Windows Product Activation. Sysprep can reset Windows Product Activation up to three times.
- You must use only the version of Sysprep that is installed with the Windows image that you intend to configure
- Only an administrator can run Sysprep.
- Only one instance of Sysprep can run at a time.
- Sysprep must not be used on upgrade installation types. Run Sysprep only on clean installations.
- The Sysprep tool runs only if the computer is a member of a workgroup, not a domain. If the computer is joined to a domain, Sysprep removes the computer from the domain.
- You can run the Sysprep command up to 8 times on a single Windows image. After that you must recreate your Windows image.
- Windows Operating System ISO
- Windows ADK to create a WinPE ISO (Download)
Create WinPE ISO
Start the DISM (Deployment and Imaging Tools Environment) Run as administrator.
- Run the below command for copies amd64 boot files.
copype amd64 C:\WinPE_amd64
Started creating Windows PE working directory in specified location.
- Once Windows PE working directory is successfully created. Use MakeWinPEMedia with the /ISO option to create an ISO file that contains the WinPE files.
MakeWinPEMedia /ISO C:\WinPE_amd64 C:\WinPE_amd64\WinPE_amd64.iso
The WinPE ISO has successfully generated.
Why we need Virtual Machine to prepare for capturing?
Tips! Building image from a VM also allows you to use Checkpoint/state restores,with checkpoint you can revert back your operating system state to any saved state later which are very useful to run right before you begin the capture process.That is value added feature for experimenting with software or tweaks that may cause problems in operating system.
Capturing an image from hardware will result in driver injection failure on several new models coming out now.When building a universal image for deployment, you absolutely do not want any hardware-specific configurations in your image.
Additional Tips & Tricks
While preparing system to capture, you have to consider these steps
- Perform a clean installation of Windows Operating System.
- During installation create a local Administrator account.
- After installation is complete, log in to the system with created local Administrator account.
• Before connecting with network, need to ensure that the Windows store apps does not get automatically updated.
Apply Local GPO Computer Configuration/Administrative Templates/Windows Components/Store Enable -Turn off Automatic Download and Install of updates policy
Perform ‘Prepare for image capture’ prerequisite tasks
- Check for Windows update to install the latest patches to the system.
- Don’t include drivers in captured Image.
- Don’t install any Microsoft Store apps using the Microsoft Store.
- Verify that necessary applications, updates and language packs are installed on Windows, Time Zone is configured and validate other system personalization.
- Before start capturing, clean up your system.
- Remove Quick Access history from file explorer.
- Run Disk Clean-up, empty the Recycle Bin, Some other common directories that can be cleaned up include: %LocalAppData%\temp,C:\Windows\Temp.
- Delete all profiles before running SYSPREP. The only profiles that should be in WIM is Administrator and Default.
- Remove unwanted Built-in apps form Windows Store.
Why should we generalize the Image?
We need to generalize the image to removes unique specific information, replace the Computer SID related to an image and make ready for deployment in different platforms.
Generalize Image and Run Sysprep
Insert Disk to mount the WinPE ISO (created explained in the above section) file by providing the path where ISO file located. That will be needed to boot the prepared image in WinPE to start the capturing.
Once the ISO file is mounted, it will be appear as shown below
- Use SYSPREP to prepare the system for capture
- Sysprep can be executed in two modes either through the GUI or Command prompt.
Start the Sysprep.exe utility Run as administrator located in folder C:\Windows\System32\sysprep directory.
- Tick the Generalize checkbox and select Shutdown options.
- Shutdown – Once sysprep complete, machine will automatically shutdown.
- Click on OK to start the process.
- Sysprep started running. Please wait for few moments! Once Sysprep completes, machine will shutdown after processing the changes.
- Start command prompt Run as administrator.
- Go to Sysprep folder to locate Sysprep utility and type the following command for execution.
Sysprep.exe /generalize /oobe /shutdown
Sysprep started running. Please wait for few moments! Once Sysprep completes, machine will shutdown after processing the changes.
The system generalizes the images and shutting down. Start the virtual machine, your virtual machine should appear like this.
Capture Windows Image after Generalize
Boot the virtual machine with Windows PE media.
You may be prompted to “Press any key to boot from CD or DVD…..“. Go ahead and press key.
Note: You may need to click inside the window to ensure that your keystrokes are sent to the virtual machine.
The machine should boot to the Command prompt for PE, identified as X:\
Important ! System must be connected with stable network to save the Image file to network share.
- Identify the network IP address where you will save the capture image.
- Use net use command to map a network shared folder to save the image.
- If prompted provide the user credentials for connection.
Run the following Dism command to capture the Windows partition. For Example :
Dism /Capture-Image /Compress:maximum /ImageFile:\\<NetworkSharePath>\SurfacePro.wim /CaptureDir:D:\ /Name:"SurfacePro"
/ImageFile: Specifies the path of file where the image will save.
/Compress: Specifies the type of compression used for the initial capture operation. The
maximum option provides the best compression.
/CaptureDir: Specifies the directory to which the image was applied.
Note: Assigning of drive letters to partitions is handled by WinPE when it first boots up, normally assigns the System Reserved partition a drive letter C: and the OS partition a drive letter D:
Here the image capture is running.
The Image file is successfully captured in shared folder, Copy the image and use for deployment.
Deploy capture Image
To deploy the capture image either we can use WinPE or Microsoft Deployment Tools which will be describe later.
Windows image will cause Sysprep to fail when you update an app from the Microsoft Store, that app becomes tied to the logged in user account.
Review the log file at %Windir%\System32\Sysprep\Panther\setupact.log. The following error appears in the log files
This Microsoft article discusses an issue that occurs when you remove or update a provisioned microsoft store app.
To resolve this issue, remove the appx package for the user. You will get package information from log file.
- Start Powershell run as administrator.
- Type the following command to remove the package.
Remove-AppxPackage -Package <packagefullname>from PowerShell.