Passing custom error messages from script to app deployment monitoring?

Hello,

in my company, sometimes we use scripts (powershell) to achieve certain goals on target machines. Perfectly normal thing. But we would like to know when something goes wrong. Most scripts return success to sccm when finished, and monitoring such deployments give nice, green circles, and 100% compliance. That's because script deployed via package or application is always successful, unless something messes it up. We do have custom error handling, and logs for every script... but I would like to have a tool that allows me to see internal errors in the description of an event, returned in SCCM deployment monitoring pane.

The closest I managed to get with the issue, was using 'exit X' command in Powershell, when stumbling on an error. It does in fact show up as 'error' in SCCM monitoring pane, but I was not able to pass the description of the error in any way. SCCM simply uses exit code in the description column, and technician has to intepret it by self.

My question is - is there any known way, to pass application deployment errors to SCCM from inside of a script?

I really would like to pass exit code as a MessageID, and a string as a description.

March 6th, 2015 9:38am

With packages, you can create custom MIF files that ConfigMgr will pick up and make available. Within these MIF files you typically supply extended information above and beyond simple error codes. I honestly don't know if you can use MIF files with Applications though.

So, the question is, are you using packages or applications?

Free Windows Admin Tool Kit Click here and download it now
March 6th, 2015 10:23am

I would probably like to have such an option with both applications and packages, but at this moment the issue is purely package-related.

I will look into whole MIF files idea. I assume that as a result my script should write all neccessary information to the file, which will be later on picked up by SCCM agent and passed to the server?

March 6th, 2015 11:21am

Correct.

When doing research, you won't find any current documentation or references. Make sure you look for information relating to either SMS 2.0 or SMS 2003.

Free Windows Admin Tool Kit Click here and download it now
March 6th, 2015 11:23am

OK, I am slowly starting to figure it out.

Found this handy script:

http://equebalahmad.blogspot.com/2010/11/sccm-deployment-generating-mif-file_28.html

I rewrote it to PS and included as part of my package deployment. (An important note here, for anyone who wishes to use it in PS - remember to set file encoding to ANSI, as in default unicode encoding SCCM will report parsing errors and skip the file entirerly).

Whole thing works almost perfectly now. Last bumb is that status is set to "FailureNonRetry" everysingle time, even though I use option "Rerun if failed previous attempt". Any idea why does it set it this way? 

March 9th, 2015 10:50am

Yep, wrote a whole post on that: http://blog.configmgrftw.com/configmgr-and-failed-program-retry/
Free Windows Admin Tool Kit Click here and download it now
March 9th, 2015 10:59am

Thanks for that, it's really helpful.

1 thing though - I noticed that even though in execmgr log I see information about "FailureNonRetry", the deployment is being retried on schedule. I think it's because MIF file is set to notice about error, but the script itself returned 0, as a success. As a result I recieve something like "program X failed with exit code 0" (will check exact phrasing tomorrow at work). Should I add non-fatal exit code to my script ontop of generating MIF file? Just not to have messed up execmgr log? 

March 9th, 2015 1:25pm

Unfortunately, now you've gone off into something I've never explicitly explorer or researched so I honestly don't know. You'll have to test.
Free Windows Admin Tool Kit Click here and download it now
March 9th, 2015 2:41pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics