You want to run a script against a computer and then based on the exit code, run another task.
ITMS 8.x
The first step is to create the tasks you want to run. In this example I will be using the tasks Update Client Configuration and Get IP Configuration. I will also create a sample script task to test with. The following sample script task will be used:
$folderPath = "C:\nse"
if (Test-Path $folderPath) {
$items = Get-ChildItem $folderPath
if ($items.Count -eq 0) {
# Folder is empty
exit 1
} else {
# Folder has items
exit 2
}
} else {
# Folder does not exist
exit 0
}
The script above is checking the directory c:\nse. If the directory exists and is empty, exit code of 1 is returned. If the directory exists and has items in it, exit code of 2 is thrown. If the folder does not exist, exit code of 0 is thrown.
We now need to create a client task job to run our tasks.
The following screenshot shows how this is setup.
The first part of the job is to run the client task Return Code Test. This runs the script task above.
We then add a new condition to the job which will check the previous script task for a return code. It matches 2, it will run Update Client Configuration. If it matches 1, it will run Get IP Configuration.
You can now create your own client task jobs based on exit codes from your scripts that can trigger other tasks.