Jump to content

What classifies as a failed Automation Task?


ElasticIT
 Share

Recommended Posts

Hi Guys,

 

 

Apologies in advance for the long post. I've been playing around with Automation Tasks and wanted to know what will cause the task to be flagged as failed or successful. Basically I created a test task with a test machine in a test scope, added a bunch of random scripts to the task and ran it. All looked good and comes back as executed successfully. It wasn't until I actually go into the Execution History and look at the output that I find that some haven't actually completed successfully at all. One example is the Clean Temporary Files powershell script in which it receives an "Access Denied" message but continues on, I'm guessing due to the "-ErrorAction SilentlyContinue" flag:

image.png.8b501f8417d64585579bd7cfe8fe9455.png

I guess the point I'm getting at is that if the Automation Tasks all show successful but really one of the scripts didn't actually complete the job it set out to do, then in my books that's not a successful completion. The only way to check if it did actually run correctly is by going into the execution history and manually checking the output of the script. That could be quite painful if it was run against dozens of machines and kind of goes against what one tries to do when automating multiple tasks.

 

So, is the Automation Task flagged as successful if it just executes the scripts, not whether the scripts actually complete properly?

 

Cheers,

Clive

 

Link to comment
Share on other sites

  • Staff

Hi ElasticIT,

You will need to configure the exit code for your script (exit code 0 - success, exit code 1 - failure).

Example:

$files = @(get-childitem $fullpath)
if($files.Count -gt $count){exit 1}
else{exit 0}

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...