If you ever find yourself in a position where you need to repair the SCCM client on a machine or server, you can run the script below. The script below will force a repair, but it can take some time to run (close to 30 mins).
CLS
#Do a repair on CCM
Rename-Item -Path "C:\Windows\CCM\StateMessageStore.sdf" -NewName "C:\Windows\CCM\StateMessageStore.sdf.bak" -Force -Confirm:$False
Rename-Item -Path "C:\Windows\CCM\StateMessageStore.sqlce" -NewName "C:\Windows\CCM\StateMessageStore.sqlce.bak" -Force -Confirm:$False
C:\Windows\ccm\ccmrepair.exe
#----- Cleanup
$Content = Get-Content -Path "C:\Windows\CCM\Logs\UpdatesDeployment.log"
$TopicID = "{$([regex]::Matches((($Content | Select-Object | Where-Object {$_ -like "*Progress*"})[0]), "(?<=\{).+?(?=\})").Value)}"
stop-service -name "ccmexec"
get-wmiobject -namespace "root\ccm" -class "SMS_MaintenanceTaskRequests" | remove-wmiobject
get-wmiobject -namespace "root\ccm\xmlstore" -class "xmldocument" | remove-wmiobject
get-wmiobject -namespace "root\ccm\citasks" -class "CCM_citask" | remove-wmiobject
get-wmiobject -namespace "root\CCM\SoftwareUpdates\DeploymentAgent" -class "CCM_AssignmentJobEx1" | remove-wmiobject
get-wmiobject -namespace "root\CCM\SoftwareUpdates\DeploymentAgent" -class "ccm_updatesjob" | remove-wmiobject
Get-WmiObject -namespace "root\ccm\softwareupdates\deploymentagent" -query "select * from ccm_assignmentcompliance where assignmentid='$TopicID'" |Remove-WmiObject
Get-wmiobject -Namespace "root\ccm\statemsg" -query "select * from ccm_statemsg where topicid='$TopicID'" |Remove-WmiObject
start-service -name "ccmexec"