Worklet: Remove SCCM Agent

If anyone else is in the same boat of wanting to remove Microsoft System Center Configuration Manager agents from endpoints and servers this is the worklet we used to accomplish it.

Evaluation script (cache folder only exists if client was configured):

if( Test-Path -Path "C:\Windows\ccmcache" )
{
    exit 1
}

Remediation script (using official Microsoft method):

$process = Start-Process -FilePath "C:\Windows\ccmsetup\ccmsetup.exe" -ArgumentList '/uninstall' -PassThru
Exit $process.ExitCode
1 Like