There may come a time where you need to uninstall or reinstall Software Center, whether it be for troubleshooting purposes or just setting up a new system. If you’re like me, you’ve found that it is not a simple process. The two PowerShell scripts below are all you need to accomplish both tasks.
Uninstall
The first script we will work on is for uninstalling Software Center. Save the following script as a .ps1 file and run it using PowerShell ISE.
Set-ExecutionPolicy Bypass -Scope Process -Force
#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
#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
You should see the below output:

You will need to restart your computer at this point.
Install
Installing Software Center will include a few more steps. We will be copying the client installation executable from the server that has SCCM installed. You will need to edit the Copy-Item line. You will also need to edit the final line, adding your Management Point and Site Code.
Set-ExecutionPolicy Bypass -Scope Process -Force
New-Item -ItemType directory -Path c:\Client
Copy-Item -path “\\SCCM-Server\c$\Program Files\Microsoft Configuration Manager\Client\ccmsetup.exe” -Destination c:\Client
cd c:\Client
.\ccmsetup.exe /mp:SCCM-server.mycompany.com SMSSITECODE=CCM1
To check on the status of the installation, you can use the Configuration Manager Trace Log Tool (CMTrace.exe) located in C:\Windows\CCM.
The log file we will be searching for is the ccmsetup.log located in C:\Windows\CCMSetup\Logs
Once the Software Center installation is complete, you should see the final line in the log:
CcmSetup is exiting with return code 0.
Return code 0 indicates the installation was successful and the computer needs to be restarted.