← Back to articles Intune

Fix Updates Issue for Comanaged Devices

Fix Updates Issue for Comanaged Devices
Executive Overview: When migrating co-managed endpoints to pure cloud-native Intune management, stale Configuration Manager (SCCM/MEMCM) client components can lock Windows Update policies. This guide details the root cause and provides a reliable removal procedure.

When transitioning Windows endpoints from Microsoft Configuration Manager (SCCM/MEMCM) co-management to 100% cloud-native Microsoft Intune, lingering SCCM client remnants frequently block Windows Update for Business (WUfB) policies from taking effect. This guide provides the complete cleanup procedure and PowerShell detection/remediation script to cleanly retire the legacy SMS Agent and restore Intune update orchestration.

Script to Uninstall SCCM from Devices through Intune

Detection Script:

# Check for SCCM client presence
$path = Test-Path -Path "C:\Windows\ccmsetup\ccmsetup.exe"

if ($path) {
    Write-Host "SCCM Client Exists. Running Remediation."
    Exit 1  # Indicates that remediation is needed
} else {
    Write-Host "SCCM Client Does Not Exist."
    Exit 0  # Indicates no remediation needed
}

Explanation:

The detection script checks whether the SCCM client setup file exists by testing the path. It exits with a code 1 if the file is found, indicating the need for remediation, otherwise it exits with a code 0.

Remediation Script:

Write-Host "Starting SCCM Client Uninstallation Process" -ForegroundColor Yellow

# Initialize a success flag
$success = $true

Try {
    # Uninstall SCCM Client
    Write-Host "Uninstalling SCCM Client..." -ForegroundColor Yellow
    if (Test-Path -Path "C:\Windows\ccmsetup\ccmsetup.exe") {
        Start-Process -FilePath C:\Windows\ccmsetup\ccmsetup.exe -ArgumentList "/uninstall" -Wait -ErrorAction Stop
    }

    # Wait briefly for uninstallation to complete
    Start-Sleep -Seconds 10

    # Stop SCCM services and processes if they exist
    if (Get-Service ccmexec -ErrorAction SilentlyContinue) {
        Write-Host "Stopping SCCM Service: ccmexec" -ForegroundColor Yellow
        Stop-Service ccmexec -Force -ErrorAction Stop
    }

    if (Get-Process ccmsetup -ErrorAction SilentlyContinue) {
        Write-Host "Stopping SCCM Setup Process: ccmsetup" -ForegroundColor Yellow
        Stop-Process -Name ccmsetup -Force -ErrorAction Stop
    }

    # Wait again for cleanup tasks to complete
    Start-Sleep -Seconds 10

    # Remove SCCM directories
    Write-Host "Removing SCCM directories..." -ForegroundColor Yellow
    Remove-Item -Path "$($Env:WinDir)\CCM" -Force -Recurse -ErrorAction SilentlyContinue
    Remove-Item -Path "$($Env:WinDir)\CCMSetup" -Force -Recurse -ErrorAction SilentlyContinue
    Remove-Item -Path "$($Env:WinDir)\CCMCache" -Force -Recurse -ErrorAction SilentlyContinue

    # Remove SCCM configuration file
    Write-Host "Removing SCCM configuration files..." -ForegroundColor Yellow
    Remove-Item -Path "$($Env:WinDir)\smscfg.ini" -Force -Recurse -ErrorAction SilentlyContinue

    # Remove SCCM registry keys
    Write-Host "Removing SCCM registry keys..." -ForegroundColor Yellow
    $registryPaths = @(
        'HKLM:\Software\Microsoft\SystemCertificates\SMS\Certificates\*',
        'HKLM:\SOFTWARE\Microsoft\CCM',
        'HKLM:\SOFTWARE\Wow6432Node\Microsoft\CCM',
        'HKLM:\SOFTWARE\Microsoft\SMS',
        'HKLM:\SOFTWARE\Wow6432Node\Microsoft\SMS',
        'HKLM:\Software\Microsoft\CCMSetup',
        'HKLM:\Software\Wow6432Node\Microsoft\CCMSetup',
        'HKLM:\SYSTEM\CurrentControlSet\Services\CcmExec'
    )
    foreach ($path in $registryPaths) {
        Remove-Item -Path $path -Force -Recurse -ErrorAction SilentlyContinue
    }

    # Wait for WMI namespace updates
    Start-Sleep -Seconds 5

    # Remove SCCM-related WMI namespaces
    Write-Host "Removing SCCM WMI namespaces..." -ForegroundColor Yellow
    $wmiNamespaces = @(
        "Select * From __Namespace Where Name='CCM'",
        "Select * From __Namespace Where Name='CCMVDI'",
        "Select * From __Namespace Where Name='SmsDm'",
        "Select * From __Namespace Where Name='sms'"
    )
    foreach ($query in $wmiNamespaces) {
        Get-CimInstance -Query $query -Namespace "root" -ErrorAction SilentlyContinue | Remove-CimInstance -ErrorAction SilentlyContinue
    }

    Write-Host "SCCM Uninstallation Process Completed Successfully." -ForegroundColor Green

    # Final wait to handle Intune timing/sync delay
    Write-Host "Waiting briefly to ensure sync with Intune..." -ForegroundColor Yellow
    Start-Sleep -Seconds 30

} Catch {
    Write-Host "An error occurred during SCCM removal: $($_.Exception.Message)" -ForegroundColor Red
    $success = $false
}

# Exit with success or failure code
if ($success) {
    Exit 0  # Indicates success
} else {
    Exit 1  # Indicates failure
}

Explanation:

The remediation script performs uninstallation of the SCCM client, stops related services, deletes their associated directories, configuration files, registry keys, and WMI namespaces. Each step is logged to the host to provide feedback during execution, ensuring the legacy SCCM components are thoroughly cleaned.

Was this article helpful?

🎯
MSEndpoint Academy

Assess Your Microsoft 365 & Intune Skills (MD-102)

100% Free • 5 Min

Applying this guide in production? Test your technical readiness against real exam scenarios from Microsoft 365 Certified: Endpoint Administrator (MD-102). Identify your strengths and knowledge gaps instantly.

💡 Express Knowledge Check Question 1 of 10

Which official utility is required to convert a Win32 application installer (.exe) into the package format (.intunewin) for deployment via Microsoft Intune?

🔒 100% Free • 📊 Instant Scorecard • 🤖 AI Explanations
Take Full Diagnostic Exam (10 Questions) →

🎓 Ready to go deeper?

Practice real MD-102 exam questions, get AI feedback on your weak areas, and fast-track your Intune certification.

Start Free Practice → Book a Session
Souhaiel Morhag
Souhaiel Morhag
Microsoft Endpoint & Modern Workplace Engineer

Souhaiel Morhag is a Microsoft Intune and endpoint management specialist with hands-on experience deploying and securing enterprise environments across Microsoft 365. He founded MSEndpoint.com to share practical, real-world guides for IT admins navigating Microsoft technologies — and built the MSEndpoint Academy at app.msendpoint.com/academy, a dedicated learning platform for professionals preparing for the MD-102 (Microsoft 365 Endpoint Administrator) certification. Through in-depth articles and AI-powered practice exams, Souhaiel helps IT teams move faster and certify with confidence.

Related Articles

Popular on MSEndpoint