{"id":116,"date":"2018-05-25T03:39:56","date_gmt":"2018-05-25T03:39:56","guid":{"rendered":"http:\/\/michaelschultz.net\/tech\/?p=116"},"modified":"2018-06-28T21:47:13","modified_gmt":"2018-06-28T21:47:13","slug":"translating-error-codes-to-error-messages-in-our-configman-reports","status":"publish","type":"post","link":"https:\/\/michaelschultz.net\/tech\/translating-error-codes-to-error-messages-in-our-configman-reports\/","title":{"rendered":"Translating error codes to error messages in your ConfigMgr reports."},"content":{"rendered":"<p>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.\u00a0 Unfortunately, as nice as error codes are to have, we don\u2019t know what all of them mean so plain text reason for an error is helpful. \u00a0I am going to show you one way to do just that.<\/p>\n<p><!--more-->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.<\/p>\n<p>I run the following and as you can see -2147467262 doesn\u2019t tell you a lot.<\/p>\n<div class=\"codecolorer-container sql default\" style=\"overflow:auto;white-space:nowrap;width:500px;\"><div class=\"sql codecolorer\"><span class=\"kw1\">SELECT<\/span> <span class=\"kw1\">DISTINCT<\/span> ResourceID<span class=\"sy0\">,<\/span> ErrorCode<br \/>\n<span class=\"kw1\">FROM<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 v_CIErrorDetails<br \/>\n<span class=\"kw1\">ORDER<\/span> <span class=\"kw1\">BY<\/span> ErrorCode<\/div><\/div>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-118\" src=\"https:\/\/i0.wp.com\/michaelschultz.net\/tech\/wp-content\/uploads\/2018\/05\/errorcodes.jpg?resize=369%2C357\" alt=\"\" width=\"369\" height=\"357\" srcset=\"https:\/\/i0.wp.com\/michaelschultz.net\/tech\/wp-content\/uploads\/2018\/05\/errorcodes.jpg?w=369&amp;ssl=1 369w, https:\/\/i0.wp.com\/michaelschultz.net\/tech\/wp-content\/uploads\/2018\/05\/errorcodes.jpg?resize=300%2C290&amp;ssl=1 300w\" sizes=\"auto, (max-width: 369px) 85vw, 369px\" \/><\/p>\n<p>Let\u2019s 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).<\/p>\n<p>Here is what it looks like in Report Builder<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-120\" src=\"https:\/\/i0.wp.com\/michaelschultz.net\/tech\/wp-content\/uploads\/2018\/05\/report1.jpg?resize=519%2C223\" alt=\"\" width=\"519\" height=\"223\" srcset=\"https:\/\/i0.wp.com\/michaelschultz.net\/tech\/wp-content\/uploads\/2018\/05\/report1.jpg?w=519&amp;ssl=1 519w, https:\/\/i0.wp.com\/michaelschultz.net\/tech\/wp-content\/uploads\/2018\/05\/report1.jpg?resize=300%2C129&amp;ssl=1 300w\" sizes=\"auto, (max-width: 519px) 85vw, 519px\" \/><\/p>\n<p>And here is the report<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-121\" src=\"https:\/\/i0.wp.com\/michaelschultz.net\/tech\/wp-content\/uploads\/2018\/05\/report2.jpg?resize=240%2C214\" alt=\"\" width=\"240\" height=\"214\" \/><\/p>\n<p>We need to reference SrsResources.dll and use an expression to convert the error code to the text found in the DLL.<\/p>\n<p>Right click in an area outside of the report and go to Report Properties. Go to References and Add a new assembly.\u00a0 Type in the following:<\/p>\n<blockquote><p><strong>SrsResources, culture=neutral<\/strong><\/p><\/blockquote>\n<p>And click OK.<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-117\" src=\"https:\/\/i0.wp.com\/michaelschultz.net\/tech\/wp-content\/uploads\/2018\/05\/addassembly.jpg?resize=697%2C640\" alt=\"\" width=\"697\" height=\"640\" srcset=\"https:\/\/i0.wp.com\/michaelschultz.net\/tech\/wp-content\/uploads\/2018\/05\/addassembly.jpg?w=697&amp;ssl=1 697w, https:\/\/i0.wp.com\/michaelschultz.net\/tech\/wp-content\/uploads\/2018\/05\/addassembly.jpg?resize=300%2C275&amp;ssl=1 300w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>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.\u00a0 Replace the currect expression with <strong>=SrsResources.Localization.GetErrorMessage(Fields!ErrorCode.Value,&#8221;en-US&#8221;)<\/strong> but the Field may different for your report.\u00a0 For me the column is ErrorCode. Click OK and rerun the report.<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-119\" src=\"https:\/\/i0.wp.com\/michaelschultz.net\/tech\/wp-content\/uploads\/2018\/05\/expression.jpg?resize=590%2C471\" alt=\"\" width=\"590\" height=\"471\" srcset=\"https:\/\/i0.wp.com\/michaelschultz.net\/tech\/wp-content\/uploads\/2018\/05\/expression.jpg?w=590&amp;ssl=1 590w, https:\/\/i0.wp.com\/michaelschultz.net\/tech\/wp-content\/uploads\/2018\/05\/expression.jpg?resize=300%2C239&amp;ssl=1 300w\" sizes=\"auto, (max-width: 590px) 85vw, 590px\" \/><\/p>\n<p>The report now shows the error message text and not the error code.<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-122\" src=\"https:\/\/i0.wp.com\/michaelschultz.net\/tech\/wp-content\/uploads\/2018\/05\/result.jpg?resize=201%2C129\" alt=\"\" width=\"201\" height=\"129\" \/><\/p>\n<p>I took it a little further and included the error codes in two columns using the following query.<\/p>\n<div class=\"codecolorer-container sql default\" style=\"overflow:auto;white-space:nowrap;width:500px;\"><div class=\"sql codecolorer\"><span class=\"kw1\">SELECT<\/span> <span class=\"kw1\">DISTINCT<\/span> ResourceID<span class=\"sy0\">,<\/span> ErrorCode <span class=\"kw1\">AS<\/span> <span class=\"st0\">'Message'<\/span><span class=\"sy0\">,<\/span> ErrorCode<br \/>\n<span class=\"kw1\">FROM<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 v_CIErrorDetails<br \/>\n<span class=\"kw1\">ORDER<\/span> <span class=\"kw1\">BY<\/span> ErrorCode<\/div><\/div>\n<p>I use this this expression on the Message field<\/p>\n<blockquote style=\"width: 745px; height: 40px;\"><p><strong>=SrsResources.Localization.GetErrorMessage(Fields!Message.Value,&#8221;en-US&#8221;)<\/strong><\/p><\/blockquote>\n<p>And now I have the error code and the error message.<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-123\" src=\"https:\/\/i0.wp.com\/michaelschultz.net\/tech\/wp-content\/uploads\/2018\/05\/result2.jpg?resize=289%2C229\" alt=\"\" width=\"289\" height=\"229\" \/><\/p>\n<p>Here are a few links for further information.<\/p>\n<ul>\n<li>Sherry Kissinger has a blog that could assist with problems if you see #Error and not the error message at <a href=\"https:\/\/mnscug.org\/blogs\/sherry-kissinger\/486-configmgr-reports-leveraging-srsresources-dll-display-error-instead-of-localized-error-descriptions\">https:\/\/mnscug.org\/blogs\/sherry-kissinger\/486-configmgr-reports-leveraging-srsresources-dll-display-error-instead-of-localized-error-descriptions<\/a><\/li>\n<li>Trevor Jones has a post on using PowerShell to translate the error codes at <a href=\"https:\/\/smsagent.wordpress.com\/2015\/06\/25\/translating-error-codes-for-windows-and-configuration-manager\/\">https:\/\/smsagent.wordpress.com\/2015\/06\/25\/translating-error-codes-for-windows-and-configuration-manager\/<\/a>. 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 <a href=\"https:\/\/smsagent.wordpress.com\/2015\/07\/06\/create-a-database-of-error-codes-and-descriptions-for-windows-and-configmgr\/\">https:\/\/smsagent.wordpress.com\/2015\/07\/06\/create-a-database-of-error-codes-and-descriptions-for-windows-and-configmgr\/<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>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.\u00a0 Unfortunately, as nice as error codes are to have, we don\u2019t know what &hellip; <a href=\"https:\/\/michaelschultz.net\/tech\/translating-error-codes-to-error-messages-in-our-configman-reports\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Translating error codes to error messages in your ConfigMgr reports.&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,26,6],"tags":[9,7,19,21,18,20],"class_list":["post-116","post","type-post","status-publish","format-standard","hentry","category-configmgr","category-queries","category-reports","tag-compliance-settings","tag-configmgr","tag-error-code","tag-reporting","tag-sql","tag-ssrs"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p98a2r-1S","post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/comments?post=116"}],"version-history":[{"count":5,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/116\/revisions"}],"predecessor-version":[{"id":186,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/116\/revisions\/186"}],"wp:attachment":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/media?parent=116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/categories?post=116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/tags?post=116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}