
Stop DISM 87 in MDT/SCCM Tasks: Environment Variables & Paths
When deploying Windows images using Microsoft Deployment Toolkit (MDT) or System Center Configuration Manager (SCCM), administrators may experience an error linked to Deployment Image Servicing and Management (DISM): Error 87. This error is often triggered during the application of Windows updates or attempting to add or remove Windows features via command-line environments within a task sequence. Understanding the root cause of DISM Error 87 and how environment variables and paths play a role is essential for a successful deployment strategy.
Contents
- 1 Understanding DISM Error 87 in MDT/SCCM
- 2 Common Causes of DISM 87
- 3 Why Environment Variables Matter
- 4 Correct Usage of Paths and Variables
- 5 Working with Custom Scripts in Task Sequences
- 6 Ensuring Correct DISM Syntax
- 7 Logging and Troubleshooting
- 8 Preventing DISM 87 Errors in Future Deployments
- 9 Final Thoughts
- 10 FAQ
Understanding DISM Error 87 in MDT/SCCM
DISM Error 87 translates to “The parameter is incorrect”. This doesn’t immediately point to a clear cause, which can lead to some confusion. In the context of MDT or SCCM, this often happens because of improper syntax usage or misconfiguration of environment variables and paths in a task sequence. The DISM tool is very particular about command-line syntax, and anything unrecognized will cause it to fail.
Common Causes of DISM 87
There are several reasons that may lead to DISM Error 87 during a deployment:
- Incorrect DISM command syntax
- Improperly formatted image paths
- Environment variables not being resolved correctly
- Spaces in file paths without quotation marks
- Attempting to run DISM commands on a non-mounted image
In nearly all cases when run as part of a task sequence, these issues are linked with how environment variables are used — or misused — in commands or script files.
Why Environment Variables Matter
MDT and SCCM make extensive use of environment variables to manage dynamic paths such as system drive designations, logs, mount points, and package locations. Variables like %OSDTargetSystemDrive%
, %DeployRoot%
, and %SYSTEMDRIVE%
are commonly used.
If these variables are not correctly resolved due to being called out of the wrong context (such as inside a PowerShell script instead of a command line window), it can cause invalid path declarations, leading to DISM throwing an error.

Example:
If you run the following command during a task sequence:
DISM /Image:%OSDTargetSystemDrive%\ /Add-Package /PackagePath="C:\updates\feature.cab"
But the variable %OSDTargetSystemDrive%
doesn’t resolve correctly, DISM effectively sees:
DISM /Image:\ /Add-Package /PackagePath="C:\updates\feature.cab"
This is invalid and results in Error 87.
Correct Usage of Paths and Variables
To resolve this, it is important to do the following:
- Use proper quotation marks when paths contain spaces.
- Validate environment variables by echoing them before calling DISM. You can do this using a Run Command Line step in MDT or SCCM:
cmd.exe /c echo %OSDTargetSystemDrive%
If the result is blank or not as expected, the variable isn’t being set correctly.
- Predefine paths in scripts rather than relying on dynamic variables when possible. For example:
DISM /Image:D:\ /Add-Package /PackagePath="C:\updates\feature.cab"
Working with Custom Scripts in Task Sequences
When using PowerShell or CMD scripts in task sequences, it’s key to differentiate between Task Sequence Variables and actual environment variables. MDT/SCCM sets special task sequence variables that are not automatically available within standard shell sessions. You would need to pass these explicitly or use script injection logic to access them.
PowerShell Variable Access Tip:
To use task sequence variables in PowerShell, Microsoft provides access through COM interfaces:
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment $Drive = $tsenv.Value("OSDTargetSystemDrive")
This is crucial when scripting DISM usage dynamically.

Ensuring Correct DISM Syntax
The syntax DISM expects must be exact. Pay attention to the spacing and the forward slashes.
Correct Example:
DISM /Image:D:\ /Add-Package /PackagePath:D:\Updates\feature.cab
Incorrect Example:
DISM Image:D:\ Add-Package /PackagePath D:\Updates\feature.cab
The lack of forward slashes in the incorrect example will return Error 87.
Logging and Troubleshooting
Review the DISM log (C:\Windows\Logs\DISM\dism.log) and also MDT/SCCM logs (smsts.log) using tools like CMTrace. These logs will provide context like:
- Which command was executed
- Which parameters failed
- How variables were expanded
Preventing DISM 87 Errors in Future Deployments
Here are some best practices to avoid future errors:
- Always validate variable expansion before execution.
- Use full, static paths if possible, particularly when working with mounted images.
- Wrap your commands in scripts that include logging and error checks.
- Test your DISM commands outside of task sequences using the same environment.
Final Thoughts
DISM Error 87 in MDT or SCCM is common during deployments, especially when variables and paths are not correctly formed. By understanding the relationship between scripts, environment variables, and DISM command-line requirements, IT administrators can eliminate this issue and have smoother deployment processes.
Reliably using DISM within deployment tools requires not only proper syntax but also intelligent scripting and accurate use of system variables. By taking a systematic approach to scripting and validation, one can turn DISM from an error-prone utility into a powerful ally in Windows deployment automation.
FAQ
What does DISM Error 87 mean?
DISM Error 87 means “The parameter is incorrect”. It often results from bad syntax or unresolved variables in command lines.
Can I use PowerShell to run DISM commands during task sequences?
Yes, but ensure that you access task sequence variables correctly using $tsenv
. Also, respect DISM’s strict syntax requirements.
How do I test my DISM commands before using them in a task sequence?
Create a test environment (such as a VM) and run identical commands manually via command prompt or PowerShell to ensure they function correctly with static paths.
Why is my DISM path not working inside the deployment task?
Likely because the image path uses a variable that wasn’t expanded correctly. Always validate your variables using echo
or logging.
Where can I find DISM logs?
The DISM logs are typically located at C:\Windows\Logs\DISM\dism.log
. These logs give detailed information about command processing and errors.