~sporiff/ccm-removal

6b71ec5bc119eed3817dc36c06b53bbfddfb8240 — Ciarán Ainsworth 1 year, 10 months ago 64f80b4
Add Script and Readme

This reverts commit 1dadd6632fd3e14b1d2cddc0b0fe8fdd52406128.
2 files changed, 54 insertions(+), 0 deletions(-)

A CCM-Removal.ps1
A Readme.md.txt
A CCM-Removal.ps1 => CCM-Removal.ps1 +53 -0
@@ 0,0 1,53 @@
Start-Process -FilePath 'C:\Windows\ccmsetup\ccmsetup.exe' -Args "/uninstall" -Wait -NoNewWindow

# wait for exit
$CCMProcess = Get-Process ccmsetup -ErrorAction SilentlyContinue
try{
    $CCMProcess.WaitForExit()
}catch{

}

# Stop Services
Stop-Service -Name ccmsetup -Force -ErrorAction SilentlyContinue
Stop-Service -Name CcmExec -Force -ErrorAction SilentlyContinue
Stop-Service -Name smstsmgr -Force -ErrorAction SilentlyContinue
Stop-Service -Name CmRcService -Force -ErrorAction SilentlyContinue

# wait for exit
$CCMProcess = Get-Process ccmexec -ErrorAction SilentlyContinue
try{
    $CCMProcess.WaitForExit()
}catch{

}

# Remove WMI Namespaces
Get-WmiObject -Query "SELECT * FROM __Namespace WHERE Name='ccm'" -Namespace root | Remove-WmiObject
Get-WmiObject -Query "SELECT * FROM __Namespace WHERE Name='sms'" -Namespace root\cimv2 | Remove-WmiObject

# Remove Services from Registry
$MyPath = “HKLM:\SYSTEM\CurrentControlSet\Services”
Remove-Item -Path $MyPath\CCMSetup -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path $MyPath\CcmExec -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path $MyPath\smstsmgr -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path $MyPath\CmRcService -Force -Recurse -ErrorAction SilentlyContinue

# Remove SCCM Client from Registry
$MyPath = “HKLM:\SOFTWARE\Microsoft”
Remove-Item -Path $MyPath\CCM -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path $MyPath\CCMSetup -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path $MyPath\SMS -Force -Recurse -ErrorAction SilentlyContinue

# Remove Folders and Files
$MyPath = $env:WinDir
Remove-Item -Path $MyPath\CCM -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path $MyPath\ccmsetup -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path $MyPath\ccmcache -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path $MyPath\SMSCFG.ini -Force -ErrorAction SilentlyContinue
Remove-Item -Path $MyPath\SMS*.mif -Force -ErrorAction SilentlyContinue	
Remove-Item -Path $MyPath\SMS*.mif -Force -ErrorAction SilentlyContinue	

#Remove authority from CCM
$MyPath = “HKLM:\SOFTWARE\Microsoft”
Remove-Item -Path $MyPath\DeviceManageabilityCSP -Force -Recurse -ErrorAction SilentlyContinue
\ No newline at end of file

A Readme.md.txt => Readme.md.txt +1 -0
@@ 0,0 1,1 @@
A simple script to remove all traces of the SCCM client in a task sequence. This step is to be run as an SMSTSPostAction after placing the file in a temporary location on the machine. It is to be used when trying to build machines with SCCM and then hand authority to an MDM.
\ No newline at end of file