Scripts provide a simpler and less extensive alternative to the Software Library. By using a script, you can avoid the need to manually input "create file" and "execute" commands, as the script will automatically execute them. Additionally, all the necessary fields for creating the file are already included in the script, saving you the time and effort of searching for and configuring them individually in the toolbox.
Check via Errorlevel
Scripts also allow you to check certain things through errorlevel. For example, you can create a job, that send you an email, whenever something is wrong.
As an example, let’s check the CPU usage, and send an email if the usage is too high.
First you have to create a script. If you use PowerShell as the script language, you have to use exits to determine the Errorlevel.
In this example we have exit 0 when everything is okay and exit 1, when the CPU usage is over the threshold.
After you have saved the script, you can create a job. First you have to let the script run, then you use an if clause and check for lastErrorLevel. To do that you have to drag run script from the toolbox and select the script, then drag if from the toolbox. If lets you choose a condition. One of the condition you can select is lastErrorLevel.
Check if lastErrorLevel is the same as the failed exit, in this case, if it is 1.
Then you can select what you want to do, if there is an undesired outcome. This is the job for checking the CPU usage:
In case you don’t use PowerShell, but Batch instead, you have to exit the %ERRORLEVEL% instead of a number. You have to use find to determine the ERRORLEVEL. Here is an example: