Deployment Image Servicing and Management (DISM) is a vital command-line utility that comes with Windows operating systems. It is mainly used for servicing and repairing Windows images, including those used for Windows Setup or recovery environments. However, when attempting to use DISM, users often encounter various error codes—one of the most common being Error 87. This error typically indicates a syntax issue, particularly involving the incorrect use or ordering of parameters (commonly known as “switches”). If not addressed correctly, Error 87 can prevent you from repairing a corrupted Windows image, leading to further system instability.
Understanding DISM Error 87
DISM Error 87 is a generic error that occurs when the command-line syntax is invalid. Most often, it is triggered when:
- An invalid option or switch has been used.
- Switches are written in the wrong order.
- The command is run from a non-elevated command line (lacking administrator privileges).
- An operation flag is not supported in the context used (e.g., mixing online and offline repair commands incorrectly).
The output for DISM Error 87 typically appears like this:
DISM.exe /Online /Cleanup-image /Restorehealth Error: 87 The cleanup-image option is unknown. For more information, refer to the DISM.log file.
This can be misleading because you might have written the command correctly—or so it seems. The error highlights how sensitive DISM is to syntax, spacing, and especially the order in which switches are placed.
The Correct Syntax and Switch Order
DISM commands must follow a precise structure. The order of the switches matters, and incorrectly placing them can result in Error 87. Below is the standard and correct format you should follow when attempting common tasks:
1. To Repair an Online Windows Image:
DISM /Online /Cleanup-Image /RestoreHealth
Correct switch order:
/Online
– Indicates that you’re working on the currently running operating system./Cleanup-Image
– Specifies the intention to clean up and manage the system image./RestoreHealth
– Tells DISM to scan the image for corruption and attempt a repair.
2. To Repair an Offline Windows Image:
DISM /Image:C:\Offline /Cleanup-Image /RestoreHealth
In the case of offline servicing:
/Image
replaces/Online
to point to a mounted or offline image.- The folder specified should contain a valid Windows directory structure.
Common Mistakes That Cause Error 87
Dealing with DISM can be challenging. Here are several common slip-ups that lead directly to Error 87:
- Using the wrong switch order. For example, placing
/RestoreHealth
before/Cleanup-Image
. - Typing errors such as
/clean-image
instead of/cleanup-image
. - Missing spaces between switches or the use of unsupported parameters.
- Attempting an online repair from a non-elevated Command Prompt.
Always make sure the Command Prompt is run with administrator privileges. You can do this by right-clicking Command Prompt and choosing “Run as administrator”.

Offline Image Repair with DISM: A Step-by-Step Guide
You can use DISM to repair a Windows installation that is offline. This is especially helpful in cases where the running system has failed to boot or is inaccessible. Here’s how to do it correctly:
Step 1: Mount the Offline Image
If your offline image is not yet mounted, you need to mount it using the Windows Imaging Format (WIM). Usually, your offline image directory will come from installation media or system backup.
DISM /Mount-WIM /WimFile:"D:\sources\install.wim" /Index:1 /MountDir:"C:\Offline"
This command mounts the image at index 1 from the WIM file to the specified directory.
Step 2: Run the Repair Command
DISM /Image:C:\Offline /Cleanup-Image /RestoreHealth
This tells DISM to check the offline image located at C:\Offline
and repair any inconsistencies or corruption it finds.
Step 3: Unmount and Commit Changes
DISM /Unmount-WIM /MountDir:"C:\Offline" /Commit
This will save any changes made during the repair process and release the mount directory.
Step 4: Restart the System
Once the changes are committed, reboot the machine and verify that your system is functioning normally.
Using a Source For RestoreHealth
Sometimes, DISM needs source files to complete the repair. If DISM cannot locate the necessary files online or locally, you may get additional errors like 0x800f081f. In this case, you can manually specify the source files with the /Source
switch:
DISM /Online /Cleanup-Image /RestoreHealth /Source:D:\sources\install.wim
If working with offline images:
DISM /Image:C:\Offline /Cleanup-Image /RestoreHealth /Source:D:\sources\install.wim
By adding a /LimitAccess
switch, you can force DISM to use only the provided source files and avoid accessing Windows Update:
DISM /Online /Cleanup-Image /RestoreHealth /Source:D:\sources\install.wim /LimitAccess

Tips to Avoid DISM Error 87
Here are a few strategies to help you steer clear of Error 87 when using DISM:
- Always check the syntax. Refer to the official Microsoft documentation if unsure.
- Use proper spacing between switches. Avoid accidentally joining switches together.
- Run as administrator. Administrator privileges are crucial for DISM commands to execute successfully.
- Confirm the path to the image or source file is correct and accessible from the current user context.
- Update to the latest version of Windows Assessment and Deployment Kit (ADK) if you’re working with Windows images frequently.
What to Do If Error 87 Persists?
If you’re still running into DISM Error 87 after correcting syntax and privileges, you may wish to:
- Check the DISM.log file located in
C:\Windows\Logs\DISM
for details. - Try performing a
sfc /scannow
command before attempting DISM. This System File Checker utility can resolve some basic issues. - Ensure your source files match the current OS version.
- Run a complete in-place upgrade using Windows setup media to repair the system entirely, if endpoints fail.
Conclusion
DISM is a powerful utility, but its precision can be its own worst enemy if commands aren’t formatted correctly. DISM Error 87 is a common roadblock that usually comes down to the misuse of command-line syntax or administrative permissions. By understanding the correct switch order, the distinctions between online and offline images, and proper use of source files, users can effectively utilize DISM to keep their systems in top condition.
Always ensure you’re using an elevated Command Prompt and double-check your commands carefully. When used properly, DISM can be a vital tool in your system maintenance toolkit—capable of repairing deep-seated issues without the need to reinstall Windows or rely on suspect third-party utilities.
