AgentTask - Possible to control Successful Unsuccessful?
Home  » MP Development  » AgentTask - Possible to control Successful Unsuccessful?

AgentTask - Possible to control Successful Unsuccessful?
Posted: Mon, Feb 08, 2010 5:26 AM :: Rank: 0
Author
Points: 10539
Level: System Center Expert

Hi,

I'm currently working on an Agent Task and we already had the experience that people think that the Task was successful because it stands it in the console which is only partially true as: Yes, the script ran, but not the way we wanted it to run.

So, I was wondering how we could control that.

I will try it now with throwing an exit code but I wanted to get some input in case anyone else worked out something already.

 

EDIT:

Tried it now with throw and exit 34. Both don't do the job.

Reply  
Report Abuse
Re: AgentTask - Possible to control Successful Unsuccessful?
Posted: Mon, Feb 08, 2010 5:33 AM :: Rank: 0
Author
Points: 24529
Level: System Center Expert
What I find helpful is to run the script on a test box outside off OpsMgr (or SCCM) to see if it runs correctly and I get the result I need. Then run it via the Management program in the case OpsMgr. If they is a failure we understand better the root cause. If that helps
Reply  
Report Abuse
Re: AgentTask - Possible to control Successful Unsuccessful?
Posted: Mon, Feb 08, 2010 5:40 AM :: Rank: 0
Author
Points: 10539
Level: System Center Expert

Hi,

the script works just fine, that's not the problem.

Thing is: We configure and discover our checks from the registry, and therefore we want to provide a task in the console that deploys registry keys and values. Works just fine.

However, in case some check already exists I want to return an error, so people don't think the check has been deployed successfully.

Of course it stands it in the output that the check already exists but people see a green icon and think it worked just fine.

Reply  
Report Abuse
RE: AgentTask - Possible to control Successful Unsuccessful?
Posted: Mon, Feb 08, 2010 6:04 AM :: Rank: 0
Author
Points: 29040
Level: System Center Expert

if memory serves, the success of a task is determined by the numeric response code returned, which I believe can be 0, -1 or 2 for success, fail and timeout. I believe I have these in a document and will look them up for you. Also in this situation in the past, we've actually logged an event right from the script to and raised an alert from that to tip the user off. Truth be told, if they can't see the notice you present in task output, raising an alert is probably the most notable way to say "Hey buddy, your task failed!".

 

Reply  
Report Abuse
Re: AgentTask - Possible to control Successful Unsuccessful?
Posted: Mon, Feb 08, 2010 6:58 AM :: Rank: 0
Author
Points: 10539
Level: System Center Expert

Hmm that's weird. I run a Powershell Write Action there and when I exit with some exit code it shows it as successful.

When I throw an error it exits with code 1 which should be considered as an error as well.

Will try exiting with -1 now.

EDIT: Doesn't work either ;)

Reply  
Report Abuse

Home  » MP Development  » AgentTask - Possible to control Successful Unsuccessful?
Tag Cloud
Quick Links
Top Contributors
Pete Zerger
Points: 29040
Level: System Center Expert
Simon Skinner
Points: 24529
Level: System Center Expert
Tommy Gunn
Points: 20727
Level: System Center Expert
Stefan Koell
Points: 12514
Level: System Center Expert
MadHatter
Points: 11676
Level: System Center Expert