Forum Discussion
dcdiag crash with incorrect /s parameter
- Mar 31, 2026
The issue is caused by using %computername% incorrectly with the /s parameter. The /s parameter expects a specific Domain Controller name (FQDN or NetBIOS), not a variable that may not resolve correctly in that execution context.
When %computername% does not resolve properly (for example in scheduled tasks, different shells, or remote execution), dcdiag may fail or crash because it cannot validate the target DC.
Solution:
Use a valid and resolvable Domain Controller name instead of %computername%, for example:
dcdiag /v /c /d /e /s:DC01.contoso.local > C:\Temp\dcdiag.txt
Alternatively, if you want to dynamically use the local machine name safely, use PowerShell instead of environment variables:
$dc = $env:COMPUTERNAME
dcdiag /v /c /d /e /s:$dc > C:\Temp\dcdiag.txt
Or simply run without /s if you are executing the command locally on a Domain Controller:
dcdiag /v /c /d /e > C:\Temp\dcdiag.txt
Summary:
/s parameter requires a properly resolvable DC name. Using %computername% can lead to failures depending on the execution context, so it’s safer to use a fixed DC name or PowerShell-based resolution.
The issue is caused by using %computername% incorrectly with the /s parameter. The /s parameter expects a specific Domain Controller name (FQDN or NetBIOS), not a variable that may not resolve correctly in that execution context.
When %computername% does not resolve properly (for example in scheduled tasks, different shells, or remote execution), dcdiag may fail or crash because it cannot validate the target DC.
Solution:
Use a valid and resolvable Domain Controller name instead of %computername%, for example:
dcdiag /v /c /d /e /s:DC01.contoso.local > C:\Temp\dcdiag.txt
Alternatively, if you want to dynamically use the local machine name safely, use PowerShell instead of environment variables:
$dc = $env:COMPUTERNAME
dcdiag /v /c /d /e /s:$dc > C:\Temp\dcdiag.txt
Or simply run without /s if you are executing the command locally on a Domain Controller:
dcdiag /v /c /d /e > C:\Temp\dcdiag.txt
Summary:
/s parameter requires a properly resolvable DC name. Using %computername% can lead to failures depending on the execution context, so it’s safer to use a fixed DC name or PowerShell-based resolution.