I was recently working on a set of custom reports on the configuration baseline and configuration item compliance. I noticed some systems failed on a few configuration items so I decided to bring in the ErrorCode info in from the v_CIErrorDetails view. Unfortunately, as nice as error codes are to have, we don’t know what all of them mean so plain text reason for an error is helpful. I am going to show you one way to do just that.
First, I am going to run a short SQL query to show some of the error codes I am talking about and what they look like.
I run the following and as you can see -2147467262 doesn’t tell you a lot.
FROM v_CIErrorDetails
ORDER BY ErrorCode
Let’s take that same query and use Report Builder to make a report out of it. I did alter it to just select the TOP(1).
Here is what it looks like in Report Builder
And here is the report
We need to reference SrsResources.dll and use an expression to convert the error code to the text found in the DLL.
Right click in an area outside of the report and go to Report Properties. Go to References and Add a new assembly. Type in the following:
SrsResources, culture=neutral
And click OK.
Next we need to alter the value of the ErrorCode with an expression to use the assembly and convert the error code. Right click on [ErrorCode} and select Expression. Replace the currect expression with =SrsResources.Localization.GetErrorMessage(Fields!ErrorCode.Value,”en-US”) but the Field may different for your report. For me the column is ErrorCode. Click OK and rerun the report.
The report now shows the error message text and not the error code.
I took it a little further and included the error codes in two columns using the following query.
FROM v_CIErrorDetails
ORDER BY ErrorCode
I use this this expression on the Message field
=SrsResources.Localization.GetErrorMessage(Fields!Message.Value,”en-US”)
And now I have the error code and the error message.
Here are a few links for further information.
- Sherry Kissinger has a blog that could assist with problems if you see #Error and not the error message at https://mnscug.org/blogs/sherry-kissinger/486-configmgr-reports-leveraging-srsresources-dll-display-error-instead-of-localized-error-descriptions
- Trevor Jones has a post on using PowerShell to translate the error codes at https://smsagent.wordpress.com/2015/06/25/translating-error-codes-for-windows-and-configuration-manager/. He has a second post on how he took the info from the first post and used it to create a database of the error codes that you can use in your SQL queries and reports without having to reference the assembly at https://smsagent.wordpress.com/2015/07/06/create-a-database-of-error-codes-and-descriptions-for-windows-and-configmgr/