Error “CcmSetup failed with error code 0x80041010” is a recurring issue encountered during SCCM (System Center Configuration Manager) client installation. This error is often linked to WMI (Windows Management Instrumentation) corruption, preventing the SCCM client from installing and functioning correctly.
In this article, we will look at how to automate the detection and remediation of this error using a PowerShell script. The script checks SCCM logs for the error message, performs a WMI repair if necessary, and then reinstalls the SCCM client automatically.
Error 0x80041010: Background and Objectives
When error 0x80041010 appears in the ccmsetup.log file, SCCM client installation fails, preventing centralized management of the affected devices.
Manually resolving this issue can be time-consuming, especially in environments containing hundreds or thousands of endpoints.
The goal of this script is to automate:
- SCCM log verification across a list of devices
- WMI repair when the error is detected
- Automatic SCCM client reinstallation
- Logging affected devices for tracking and reporting purposes
How the PowerShell Script Works
Detecting the Error in SCCM Logs
The script checks the ccmsetup.log file on each device listed in $machines.
If the following message is found:
CcmSetup failed with error code 0x80041010
the device is automatically added to a tracking file for remediation.
Creating and Executing the WMI Repair Script
If the error is detected, the script creates and executes a repair.bat file on the remote device.
This batch file performs the following actions:
- Stops the WMI service
- Deletes the WMI repository folder to force a rebuild
- Re-registers WMI-related DLL and MOF files
Reinstalling the SCCM Client
Once the repair process has completed, the script:
- Downloads the SCCM client installation package from a predefined source
- Launches the SCCM client installation
- Waits for completion
- Verifies that the ccmexec service is present and running
PowerShell Script
# List of computers to verify
$machines = @(
"Machine1",
"Machine2"
# Add additional machines here
)
# Log file used to track affected devices
$errorLogFile = "C:\temp\MachinesWithError.txt"
# Check each device
foreach ($machine in $machines) {
$logFilePath = "\\$machine\C$\Windows\CCMsetup\Logs\ccmsetup.log"
$errorCode = "CcmSetup failed with error code 0x80041010"
if (Test-Path -Path $logFilePath) {
$errorFound = Select-String -Path $logFilePath -Pattern $errorCode -SimpleMatch
if ($errorFound) {
# Add device to tracking file
Add-Content -Path $errorLogFile -Value $machine
# Create repair.bat
$repairScriptPath = "\\$machine\C$\Windows\Temp\repair.bat"
$repairScriptContent = @"
Net Stop winmgmt
C:
CD %SystemRoot%\System32\wbem
RD /S /Q repository
regsvr32 /s %SystemRoot%\system32\scecli.dll
regsvr32 /s %SystemRoot%\system32\userenv.dll
for /f %%s in ('dir /b /s *.dll') do regsvr32 /s %%s
scrcons.exe /regserver
unsecapp.exe /regserver
winmgmt.exe /regserver
wmiadap.exe /regserver
wmiapsrv.exe /regserver
wmiprvse.exe /regserver
mofcomp cimwin32.mof
mofcomp cimwin32.mfl
mofcomp rsop.mof
mofcomp rsop.mfl
for /f %%s in ('dir /b *.mof') do mofcomp %%s
for /f %%s in ('dir /b *.mfl') do mofcomp %%s
cd "C:\Program Files\Microsoft Policy Platform"
mofcomp ExtendedStatus.mof
"@
# Write the repair script to the remote device
Set-Content -Path $repairScriptPath -Value $repairScriptContent
# Execute the repair
Invoke-Command -ComputerName $machine -ScriptBlock { cmd /c C:\Windows\Temp\repair.bat }
# Reinstall SCCM client after repair
Invoke-Command -ComputerName $machine -ScriptBlock {
function Reinstall-SCCMClient {
try {
Start-BitsTransfer -Source "http://Primary_Server/ccm_client/ccmsetup.exe" -Destination C:\temp\ccmsetup.exe
} catch {
Write-Output "Error: Failed to download SCCM client. Exception: $_"
return
}
if (Test-Path -Path C:\temp\ccmsetup.exe) {
$arg = '/AllowMetered SMSSITECODE=Sitecode SMSMP=MP_Server'
Start-Process -FilePath C:\temp\ccmsetup.exe -ArgumentList $arg -Wait
} else {
Write-Output "Error: Download of SCCM client failed, file not found at C:\temp\ccmsetup.exe"
return
}
Start-Sleep -Seconds 120
if (Get-Service -Name "ccmexec" -ErrorAction SilentlyContinue) {
Write-Output "SCCM Client installed successfully."
} else {
Write-Output "SCCM Client installation failed."
}
}
Reinstall-SCCMClient
}
}
}
}
Error 0x80041010: Conclusion
This PowerShell script provides an automated way to remediate SCCM error 0x80041010 and perform a clean SCCM client reinstallation.
By automating WMI repair, SCCM log analysis, and client redeployment, organizations can significantly reduce administrative effort and improve endpoint management efficiency.
This approach fits naturally into a proactive Digital Workplace management strategy, helping IT teams maintain healthy SCCM clients across large-scale environments.

