About Me

My photo
HANUMANGARH, RAJASTHAN, India

Sunday 10 July 2022

Remove completly SCCM Client

 #Uninstall ccmsetup

Write-Host "Uninstalling CCMSETUP from server" -ForegroundColor Green

Start-Process -FilePath "$Env:SystemDrive\Windows\ccmsetup\ccmsetup.exe" -ArgumentList '/uninstall'


# Stop the Service "SMS Agent Host" which is a Process "CcmExec.exe"

Write-Host "Stop the Service (SMS Agent Host)" -ForegroundColor Green

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

Write-Host "Stop the Service (ccmsetup)" -ForegroundColor Green

Get-Service -Name ccmsetup -ErrorAction SilentlyContinue | Stop-Service -Force -Verbose


# Delete the folder of the SCCM Client installation: "C:\Windows\CCM"

Write-Host "clear SCCM Client installation" -ForegroundColor Green

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"

Write-Host "SCCM Client Cache of all the packages and Application" -ForegroundColor Green

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"

Write-Host "Removing SCCM Client Setup files" -ForegroundColor Green

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

Write-Host "Removing certificate GUID and SMS GUID" -ForegroundColor Green

Remove-Item -Path "$($Env:WinDir)\smscfg.ini" -Force -Confirm:$false -Verbose


# Delete the certificate itself

Write-Host "Deleting certificate" -ForegroundColor Green

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

Write-Host "Removing registry keys associated with the SCCM Client" -ForegroundColor Green

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"

Write-Host "Removing service from (Services.msc)" -ForegroundColor Green

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

Write-Host "Removing Namespaces from the WMI repository" -ForegroundColor Green

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.

Write-Host "WMI Removal in case of something goes wrong with the WMI Repository" -ForegroundColor Green

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

No comments:

Post a Comment

Export contact from Justdial

  Extract Data From JustDial using Selenium Let us see how to extract data from Justdial using Selenium and Python. Justdial is a company th...