ElasticIT Posted November 23, 2017 Posted November 23, 2017 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: 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 Â
Staff Chris Posted November 23, 2017 Staff Posted November 23, 2017 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} Â
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now