Returning script results to the user interface
The status of the script - pass or fail - can be reported to the N-sight RMM user interface (UI) through exit codes.
Where the returned exit code is zero, the script is recorded as passed, with any non-zero exit code resulting in a failure.
Exit codes 1 to 999 are reserved for use by the system scripts. As such we recommend returning an exit code greater than 1000 in your scripts to ensure the text output is displayed correctly in the N-sight RMM UI.
We support scripts up to a maximum of 65,535 characters in size and script output up to 10000 characters
Exit Code | Result |
---|---|
0 | Pass |
>0 | Fail |
1 - 999 | Reserved exit codes |
>1000 | Displays text output in the N-sight RMM UI. |
To output text from the script to the N-sight RMM UI, echo from the script to standard output (stdout).
For example in DOS Batch, VBScript, PowerShell and Bash this can be achieved by:
Script Type |
Pass |
Fail |
---|---|---|
DOS Batch
|
echo "Success Message" |
echo "Error Message" |
exit 0 |
exit 1001 |
|
VBScript
|
wscript.echo( "Success Message" ) |
wscript.echo( "Error Message" ) |
wscript.Quit(0) |
wscript.Quit(1001) |
|
PowerShell
|
Write-Host "Success Message" |
Write-Host "Error Message" |
Exit 0 |
Exit 1001 |
|
Bash |
#!/bin/bash |
#!/bin/bash |
echo "Success Message" |
echo "Error Message" |
|
exit 0 |
exit 1001 |
If using custom PowerShell scripts in the Automation Manager the script's exit codes are only consumed within the Run PowerShell Script module and not passed back to the N-sight RMM UI.
To generate an N-sight RMM UI failure where the PowerShell script fails, add an If or If/Else Control Flow condition and include the Fail Policy module.
For example, Run PowerShell Script (Extensions) > If (Control Flow) > Then > Fail Policy (Control Flow).
What do you want to do?
- View the supported script types
- Determine whether the end user can interact with the script
- Parse Command Line Arguments to the script
-
Upload the Script to the N-sight RMM UI
- Deploy the Script on one of more devices
- Learn about the Windows Automation Manager
- View script Troubleshooting suggestions
- Read our scripting FAQs