SCCM Client Complete Uninstall / Remove + Powershell Script

Why you might need to reinstall the Client

There are times that Microsoft Software Center Configuration Manager Client is just going bad. You get some strange reporting going on, updates will not install, applications not deploying, Pull Distribution Point will not distribute content, etc. There are several things you can do in order to uninstall SCCM Client.

Affiliate: Experience limitless no-code automation, streamline your workflows, and effortlessly transfer data between apps with Make.com.

How to uninstall / remove SCCM Client

*** Ccmsetup of the installed client is located in:

C:\Windows\ccmsetup\ccmsetup.exe

. Use the switch “/uninstall” to uninstall the client (from command line with elevated privileges):

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

The uninstall process is silent by design. Right after you execute the command run “Task Manager” ([Ctrl]+[Shift]+[Esc]) in “Details” tab you will see new process running: “ccmsetup.exe”. After couple of minutes process “CcmExec.exe” will disappear. When process “ccmsetup.exe” will disappear also – the uninstallation process will be finished.
*** You can find out more about SCCM Client Uninstallation from Microsoft Docs (you can find there all the information regarding the clients).

. Restart
. Open Powershell and run this script (or save it as *.ps1 file and run it in as Powershell):

# Stop the Service "SMS Agent Host" which is a Process "CcmExec.exe"
Get-Service -Name CcmExec -ErrorAction SilentlyContinue | Stop-Service -Force -Verbose

# Stop the Service "ccmsetup" which is also a Process "ccmsetup.exe" if it wasn't stopped in the services after uninstall
Get-Service -Name ccmsetup -ErrorAction SilentlyContinue | Stop-Service -Force -Verbose

# Delete the folder of the SCCM Client installation: "C:\Windows\CCM"
Remove-Item -Path "$($Env:WinDir)\CCM" -Force -Recurse -Confirm:$false -Verbose

# Delete the folder of the SCCM Client Cache of all the packages and Applications that were downloaded and installed on the Computer: "C:\Windows\ccmcache"
Remove-Item -Path "$($Env:WinDir)\CCMSetup" -Force -Recurse -Confirm:$false -Verbose

# Delete the folder of the SCCM Client Setup files that were used to install the client: "C:\Windows\ccmsetup"
Remove-Item -Path "$($Env:WinDir)\CCMCache" -Force -Recurse -Confirm:$false -Verbose

# Delete the file with the certificate GUID and SMS GUID that current Client was registered with
Remove-Item -Path "$($Env:WinDir)\smscfg.ini" -Force -Confirm:$false -Verbose

# Delete the certificate itself
Remove-Item -Path 'HKLM:\Software\Microsoft\SystemCertificates\SMS\Certificates\*' -Force -Confirm:$false -Verbose

# Remove all the registry keys associated with the SCCM Client that might not be removed by ccmsetup.exe
Remove-Item -Path 'HKLM:\SOFTWARE\Microsoft\CCM' -Force -Recurse -Verbose
Remove-Item -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\CCM' -Force -Recurse -Confirm:$false -Verbose
Remove-Item -Path 'HKLM:\SOFTWARE\Microsoft\SMS' -Force -Recurse -Confirm:$false -Verbose
Remove-Item -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\SMS' -Force -Recurse -Confirm:$false -Verbose
Remove-Item -Path 'HKLM:\Software\Microsoft\CCMSetup' -Force -Recurse -Confirm:$false -Verbose
Remove-Item -Path 'HKLM:\Software\Wow6432Node\Microsoft\CCMSetup' -Force -Confirm:$false -Recurse -Verbose

# Remove the service from "Services"
Remove-Item -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\CcmExec' -Force -Recurse -Confirm:$false -Verbose
Remove-Item -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\ccmsetup' -Force -Recurse -Confirm:$false -Verbose

# Remove the Namespaces from the WMI repository
Get-CimInstance -query "Select * From __Namespace Where Name='CCM'" -Namespace "root" | Remove-CimInstance -Verbose -Confirm:$false
Get-CimInstance -query "Select * From __Namespace Where Name='CCMVDI'" -Namespace "root" | Remove-CimInstance -Verbose -Confirm:$false
Get-CimInstance -query "Select * From __Namespace Where Name='SmsDm'" -Namespace "root" | Remove-CimInstance -Verbose -Confirm:$false
Get-CimInstance -query "Select * From __Namespace Where Name='sms'" -Namespace "root\cimv2" | Remove-CimInstance -Verbose -Confirm:$false

# Alternative command for WMI Removal in case of something goes wrong with the above.
# Get-WmiObject -query "Select * From __Namespace Where Name='CCM'" -Namespace "root" | Remove-WmiObject -Verbose | Out-Host
# Get-WmiObject -query "Select * From __Namespace Where Name='CCMVDI'" -Namespace "root" | Remove-WmiObject -Verbose | Out-Host
# Get-WmiObject -query "Select * From __Namespace Where Name='SmsDm'" -Namespace "root" | Remove-WmiObject -Verbose | Out-Host
# Get-WmiObject -query "Select * From __Namespace Where Name='sms'" -Namespace "root\cimv2" | Remove-WmiObject -Verbose | Out-Host

. Restart again before reinstalling the client
*** The script has worked in most cases, but we recommend checking after the script run that you have the three folders removed in c:\Windows.

After you uninstall the client you may check our SCCM Client Installation comprehensive guide.

7 thoughts on “SCCM Client Complete Uninstall / Remove + Powershell Script”

  1. I noticed most of the files and keys were removed during the ccmsetup.exe /uninstall command. Why not monitor win32_process for ccmsetup then execute the rest of the script after ccmsetup is gone from win32_process. Also, place test-path for each of the lines so there’s not so much red text while running the script. I don’t think there’s a restart required until all the script components have been removed (but I haven’t tested this much yet). Thanks for posting this information. Worked like a charm and the SCCM server has pushed out an updated ccmsetup client to my workstation that had a corrupt installation.

  2. You’re right it will be much easier to monitor the process and then send the restart by powershell. You can add many checks during the run to hide the red lines. This script was published for SCCM professionals to get rid of all the leftovers of the client for the maintenance purposes. It just takes more time to add these checks and for the script to run. This script should be as simple as possible without too much code as it is a maintenance tool and related for experienced users. I believe that the more code you add the more error there could be during the runs. So I don’t think all the checks are necessary, but off course you can do as you think best suits your needs. From my experience with the SCCM client removal it is best to restart after the regular /uninstall command as there are still services, registry and WMI entries that can be locked and this script simply won’t be able to remove them all. Too bad Microsoft makes it THIS hard to do something that simple. I’m glad this is worked for you!

  3. Hi please how can I solve problem that I cannot remove entire content of C:\Windows\CCM?

    Access denied

  4. Hello Martin,
    Possible issues could be:
    * Some process holds the folder – Try to find it and kill
    * You don’t have enough permissions on this host
    * Try running the script as Administrator

  5. Thank you. Worked a treat for resolving an issue. I had duplicate GUIs from clones. Uninstalling the agent from the master image was not enough.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.