Kace Script not Continuing to Task 2 after Task 1 Remediation Succeeds
I have run into this issue with running a Kace script. It is a 2 Task script that runs task 2 if task 1 succeeds. The problem is, after Task 1 successfully remediates, it ends the script with a success but doesn't log any of the steps in task 2. Then, if I run it again, Task 2 completes because Task 1 does not require remediation. So, why doesn't Task 2 execute after a successful completion of Task 1?
My script is simple.
Task 1: Check if a file C:\Tree1.txt exists, if it doesn't, the remediation step creates the file with a batch script.
Task 2: Check if a file C:\Tree2.txt exists, if it doesn't, the remediation step creates the file with a batch script.
Below is the actual steps:
Task 1
Attempts: 1
On Failure: Break
Verify:
Verify that the file “C:\Tree1.txt” exists.
On Success:
Log “Tree1.txt already Exists.” to “status”.
Remediation:
Log “Tree1.txt not found. Running Creation Script” to “status”.
Run a batch file...
Script Name: CreateTree1
Batch file: reg query HKLM\Software > C:\tree1.txt
Wait for completion
On Remediation Success:
Log “Tree1.txt Created successfully.” to “status”.
On Remediation Failure:
Log “Tree1.txt creation failed.” to “status”.
Task 2
Attempts: 1
On Failure: Break
Verify:
Verify that the file “C:\Tree2.txt” exists.
On Success:
Log “Tree2.txt already exists.” to “status”.
Remediation:
Run a batch file...
Script Name: CreateTree2
Batch file: reg query HKLM\Software > C:\tree2.txt
Wait for completion
On Remediation Success:
Log “Tree2.txt created successfully.” to “status”.
On Remediation Failure:
Log “Tree2.txt creation failed.” to “status”.
Log:
Output Log:
Running as: SYSTEM
File does not exist: C:\Tree1.txt
Launched Process: kace8412.bat
Status Log:
Tree1.txt not found. Running Creation Script
Tree1.txt Created successfully.
Activity Log:
Checking if file exists: C:\Tree1.txt
Launching program: 'C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\63\kace8412.bat' '' wait='true'
-
What Server version is this run on? I just popped in today with a similar issue running 5.5.90548. - worzie 9 years ago
-
Oddly enough... creating a new script was the answer for me. Guessing that script I had may have been corrupt? - worzie 9 years ago
Answers (4)
A "dirty" solution (if the above is the case), could be to add an additional task in between the current Task 1 and Task 2 (your current Task 2 then becomes Task 3), with the same settings as your current Task 1. Then change Task 1 to "On Failure: Continue" and set the new Task 2 to "On Failure: Break".
A better solution in my opinion would be to make one batch script that does it all (dump the registry output to the files and individually check if they exist afterwards. If they dont, set an errorlevel). Then add the batchscript as a dependency to the Kace script and just create one task which runs the batch script.
Comments:
-
Yes, this seems to be a "solution" to have it run the step twice. I was thinking about having a single step but, I want this script to install 5 prerequisite applications in a specific order. I also want it to actually log a failure when the script runs and exits at a specific step.... but it doesn't.... Oh Kace..
Thanks for the help. - pwetter 9 years ago -
Instead of duplicating Task 1, you can just set "Attempts" for Task 1 to "2". Then you should be able to leave it set to Break on failure; it should only break if Task 1 fails both times (which would indicate that the Remediation must have failed). - Dansiman 2 years ago