Thursday 2 April 2015

Status messages from SCCM task sequences via SQL.

I've got an automated server build process working well now using System Center Orchestrator and System Center Configuration Manager (SCCM), currently we poll the status messages via custom c# code within an Integration pack to determine the task sequence status. What I wanted to do was replicate the status message viewer output within our email step.

I've knocked together a crude SQL query to get this using the provided view. Please bear in mind SQL isn't my strong point.. I can get by with the help of Google! So I just thought I would provide a copy of the query here in case it is of use to anyone else..

You just need to remove or edit the WHERE clauses for the date and the machinename values where appropriate.

SELECT
 CASE [Severity] 
  WHEN '1073741824' THEN 'Informational' 
  WHEN '-1073741824' THEN 'Error' 
  WHEN '-2147483648' THEN 'Warning' 
 END AS Severity
  ,[SiteCode]
  ,[Time]
  ,[MachineName]
  ,[Component]
  ,[MessageID],
 CASE [MessageID] 
  WHEN '11124' THEN ('The task sequence execution engine started the group (' + [InsStrValue3] + ').')
  WHEN '11127' THEN ('The task sequence execution engine successfully completed the group (' + [InsStrValue3] + ').') 
  WHEN '11128' THEN ('The task sequence execution engine skipped the disabled action (' + [InsStrValue2] + ') in the group (' + [InsStrValue3] + ').') 
  WHEN '11130' THEN ('The task sequence execution engine skipped the action (' + [InsStrValue2] + ') in the group (' + [InsStrValue3] + ').')
  WHEN '11134' THEN ('The task sequence execution engine successfully completed the action (' + [InsStrValue2] + ') in the group (' + [InsStrValue3] + ') with exit code ' + [InsStrValue4] + ' Action output: ' + (COALESCE([InsStrValue5], '') + '' + COALESCE([InsStrValue6], '') + '' + COALESCE([InsStrValue7],'')+ COALESCE([InsStrValue8],'')+ COALESCE([InsStrValue9],'')+ COALESCE([InsStrValue10],''))) 
  WHEN '11135' THEN ('The task sequence execution engine failed execuiting the action (' + [InsStrValue2] + ') in the group (' + [InsStrValue3] + ') with exit code ' + [InsStrValue4] + ' Action output: ' + (COALESCE([InsStrValue5], '') + '' + COALESCE([InsStrValue6], '') + '' + COALESCE([InsStrValue7],'')+ COALESCE([InsStrValue8],'')+ COALESCE([InsStrValue9],'')+ COALESCE([InsStrValue10],'')))  
  WHEN '11138' THEN ('The task sequence execution engine ignored execution failure of the action (' + [InsStrValue2] + ') in the group (' + [InsStrValue3] + ').')  
  WHEN '11140' THEN ('The task sequence execution engine started execution of a task sequence.')  
  WHEN '11142' THEN ('The task sequence execution engine performed a system reboot initiated by the action (' + [InsStrValue2] + ') in the group (' + [InsStrValue3] + ').')  
  WHEN '11144' THEN ('The task sequence execution engine from a non-client started execution of a task sequence.')
 END AS Description 
FROM [CM_SiteCodeHere].[dbo].[vStatusMessagesWithStrings] (NOLOCK) 
WHERE MachineName = 'MyServerNameHere'
 AND Component in ('Task Sequence Engine','Task Sequence Manager','Task Sequence Action')
 AND Time BETWEEN '2015-04-02 08:30' AND GETDATE() 
ORDER BY Time DESC
  
Change the site code in the query.. CM_SiteCodeHere and apollogies for the formatting here.

1 comment:

  1. I'll apologize for the poor formatting when posted here too!

    ReplyDelete