Uninstalling the ConfigMgr (MECM / MEMCM / SCCM) client, can be as simple as running this command with administrative rights

C:\Windows\CCMSetup\CCMSetup.exe /uninstall

But when you need to cleanup ALL of the remnants of the ConfigMgr client there’s a bit more work to do.

One example is when you are moving from a Co-Managed state to a native Intune managed state.  The ConfigMgr client uninstaller may need some extra help to get enough references deleted so the Windows OMA-DM “service” and the Intune Management Extension (IME) service accept that the device is no longer Co-Managed.

Behold the power of, um, PowerShell.

The full and latest code can be obtained from GitHub.  https://github.com/ChadSimmons/Scripts/blob/default/ConfigMgr/Troubleshooting/Remove-ConfigMgrClient.ps1

#.SYNOPSIS
#   Remove-ConfigMgrClient.ps1
#   run ConfigMgr's uninstall command and cleanup leftover files, registry keys, and certificates

# Stop Services and wait for exit
Write-LogMessage -Message 'Stopping ConfigMgr services ccmsetup, ccmexec, smstsmgr, cmrcservice'
Stop-Service -Name ccmsetup -Force -ErrorAction SilentlyContinue
...
# Preserve CMTrace.exe log file viewer
...
  Copy-Item -Path "$env:SystemRoot\CCM\CMTrace.exe" -Destination $env:SystemRoot -ErrorAction SilentlyContinue
...
# Backup ConfigMgr Client logs
Write-LogMessage -Message "Archiving ConfigMgr Client logs to [$(""$env:SystemRoot\Logs"")] before uninstalling"
...
  [System.IO.Compression.ZipFile]::CreateFromDirectory("$TempPath", "$env:SystemRoot\Logs\ConfigMgrClient.zip", $([System.IO.Compression.CompressionLevel]::Optimal), $false)
...
# Run ConfigMgr client uninstall
# Get the path to ConfigMgr client's installer/uninstaller
...
  Start-Process -FilePath "$CCMSetupPath" -ArgumentList '/uninstall' -NoNewWindow #-Verb RunAs #-Wait
...
# Remove leftover folders and files
...

 

ConfigMgr Client uninstall

Fully remove the ConfigMgr client
Tagged on: