Sometimes (in my case after SCCM 2012 upgrade to R2) you may see a high number of error messages (ID 6105) produced by SMS_STATE_SYSTEM with the following description:
SMS State System message file processing processed one or more files that contained errors or invalid data. Review the statesys.log file for further details.
The STATESYS.LOG File shows the following:
SQL MESSAGE: spProcessStateReport – Error: The key for machine <AGENTNAME> (GUID:EE344EFE-A80C-483E-BAFB-E3XXXXXXXXXX) did not match the one in the database.
That means that the client system has changed SMS GUID but this change has not been reflected in SCCM DB. You have to manually reset the agent SMS GUID to fix the problem.
If you are dealing with thousand messages and hundreds of clients you can script up this operation as I did.
To get the names for affected clients you have to go to <SCCM Installation Folder>\Inboxes\auth\statesys.box\corrupt and copy all SMX files to the temporary location. Each SMS file is in fact a XML document. In order to extract system name from it I use this PowerShell script:
get-childitem *.smx | % {[xml]$statfile = get-content $_.Name
Out-File -filepath “list-of-computers.txt” -InputObject $statfile.Report.ReportHeader.Identification.Machine.NetBiosName -append
}
This script may produce several errors which could be ignored.
The list will contain a lot of duplicates. I get rid of them using Excel filter.
Once you have your list you may proceed with SMS GUID reset. To reset SCCM client SMS GUID you have to simply delete SMSCFG.INI file from %windir% and restart SMS Agent Host service. I use this script to reset SMS GUID on multiple servers:
$FullServerList = Get-Content “list-of-computers.txt”
foreach ($servername in $FullServerList ) {
If (Test-Connection -computername $servername -quiet) {
$RemoteFile = “\\”+$servername+”\Admin$\SMSCFG.INI”
If (Test-Path $RemoteFile) {
Remove-Item $RemoteFile
Write-Host “Deleting” $RemoteFile
(gwmi Win32_Service -filter “name=’ccmexec’” -computername $ServerName).StopService()
(gwmi Win32_Service -filter “name=’ccmexec’” -computername $ServerName).StopService()
} Else {Write-Host “Cannot connect to” $RemoteFile
}
} Else {Write-Host $ServerName “cannot be contacted”}
}