Actions32
- Device Actions
- Control Windows Service
- Get
- Get Activities
- Get Alerts
- Get Custom Fields
- Get Dashboard URL
- Get Disks
- Get Jobs
- Get Last Logged On User
- Get Many
- Get Network Interfaces
- Get OS Patch Installs
- Get OS Patches
- Get Policy Overrides
- Get Processors
- Get Software
- Get Software Patch Installs
- Get Software Patches
- Get Volumes
- Get Windows Services
- Reboot Device
- Run Script
- Update Custom Fields
- Ticket Actions
- Organization Actions
Device → Run Script
AI-generatedOverview
This node allows users to run scripts on a specified device using the NinjaOne API. It supports running either saved scripts from the NinjaOne library or inline PowerShell scripts. Users can specify the device by its ID, choose the script type, provide script content or select a saved script ID, and pass parameters to the script. The script can be executed either as the system user or the current user. This node is useful for automating device management tasks, running diagnostics, or executing custom commands remotely on devices managed by NinjaOne.
Use Case Examples
- Run a saved script from the NinjaOne library on a device to gather system information.
- Execute an inline PowerShell script to check the status of a Windows service on a remote device.
- Pass parameters to a script to customize its execution on different devices.
Properties
| Name | Meaning |
|---|---|
| Device ID | ID of the device on which the script will be run. |
| Script Type | Type of script to run, either a saved script from the NinjaOne library or an inline script provided by the user. |
| Script ID | ID of the saved script from the NinjaOne library to run (required if Script Type is 'Saved Script'). |
| Script Content | PowerShell script content to execute (required if Script Type is 'Inline Script'). |
| Script Parameters | Key-value pairs of parameters to pass to the script. |
| Run As | User context to run the script under, either as the system user or the current user. |
Output
JSON
deviceId- The ID of the device on which the script was run.scriptType- The type of script that was executed (saved or inline).scriptId- The ID of the saved script executed, if applicable.scriptContent- The content of the inline script executed, if applicable.scriptParameters- Parameters passed to the script.runAs- The user context under which the script was run.executionResult- The result or output of the script execution returned by the NinjaOne API.
Dependencies
- NinjaOne API
- An OAuth2 API key credential for authentication
Troubleshooting
- Ensure the device ID is correct and the device is reachable via the NinjaOne platform.
- If running a saved script, verify the script ID exists in the NinjaOne library.
- For inline scripts, ensure the PowerShell script syntax is correct and compatible with the target device.
- Check that the OAuth2 credentials are valid and have sufficient permissions to run scripts on devices.
- If the script execution fails, review the execution result or error message returned by the API for troubleshooting.
Links
- NinjaOne API Documentation - Official API documentation for NinjaOne, including endpoints for device management and script execution.