Script Library

NinjaOne Script Library provides a valuable resource for automating common IT tasks and streamlining workflows, empowering administrators to focus on strategic initiatives and improve overall efficiency. NinjaOne Script Library streamlines IT operations by automating repetitive tasks, reducing manual errors, and freeing up valuable time for strategic initiatives. From software deployment and patch management to data backup and security checks, NinjaOne Script Library offers a wide range of pre-built scripts to suit diverse IT needs.

Configuring NinjaOne Script Library

Important Notes:

  • The NinjaOne agent does not support custom scripts that issue reboots. To issue a reboot, NinjaOne’s native reboot script should be used, as this script ensures that the agent is able to properly handle the action.
  • If an automation is marked as “All” for Architecture, it runs based on what is native to the device (32 or 64 bit).
  • The following special characters cannot be used in parameters: &|;$><`!
  • You may assign scripts to a category (or multiple categories) to further organize your Automation Library. To create new categories or edit/delete existing categories, click the Categories tab in Administration > Library > Automation (see screenshot below). 
  • NinjaOne only accepts string value parameters. These include string decimal integers and checkbox options.

Administration

Scripts

The Automation Library serves as a central script repository that is agnostic to policies. NinjaOne provides a number of out-of-the-box native scripts, but you can also create and edit custom scripts, or install and run app automations. When you run custom scripts on devices, you are prompted to specify optional parameters and whether you wish to run scripts as System, Current User, or using credentials from your credential store.

Supported Script Languages

  • JavaScript
  • PowerShell
  • Batch
  • ShellScript
  • VBS Script

Local Script Retention

Scripts show up in the following folder when run on a device:

C:\ProgramData\NinjaRMMAgent\scripting

A script shows in this folder when it runs but is immediately removed once the script has completed running.

Automated Applications

Administrators can configure scripts to run or install an application. The run/install automation application options allow users to create a library of installed and running application scripts that can be added to a policy, scheduled task, or can be run on demandFor example, if you run CCleaner on endpoints, you can call on that using NinjaOne.

Once an application is installed to the Automation Library, it can be used multiple times across different organizations/devices.

Administrators can configure scripts to run or install an application.

Adding New Scripts:

Important Note: NinjaOne does not reformat the script that is pasted into the editor to match the OS where it originated. For example, a script being written on Linux will not run correctly on a Mac. That would need to go through an EOL Conversion in order for the formatting to be correct for the OS type that you are planning to run it against.

1. Navigate to Administration > Library > Automation. Then, click Add > New Script in the top right corner.

Navigate to Administration > Library > Automation. Then, click Add > New Script in the top right corner. 

The Create Script page displays.

2. Complete the fields on the right side of the page; required fields are marked with an asterisk (*). The preset parameters should be formatted according to the language requirements of each script. (For more information about parameters, please see: Automation Library: Parameters; for more information about using script variables, please see: Automation Library: Using Variables in Scripts).

The Create Script page displays.

Important Note: Command formatting changes automatically based on the language and operating system you select in the Create Script configuration pane. See below for an example of ShellScript for Mac/Linux (1) and Batch for Windows (2).

an example of ShellScript for Mac/Linux (1) and Batch for Windows (2)

3. Customers can set default “Run As” to be something other than “System.” This will change the “Run As” value automatically when running the script ad hoc or scheduling the script to run.

Customers can set default "Run As" to be something other than "System."

  • Run an ad-hoc script for a device.

Run an ad-hoc script for a device. 

Run an ad-hoc script for a device. 

Run an ad-hoc script for a device. 

4. Enter the script to the left of the script field commands. Script files can be dragged and dropped into this pane, as well.

Enter the script to the left of the script field commands.

5. If you’d like your custom script to interact with Custom Fields data, use ctrl+space to access snippets, which are building blocks that can be used to either read from or write to certain Custom Scripts. For more information about this, please see Custom Fields: CLI and Scripting.

6. Click Save in the top right corner. The script is now available for use in a Scheduled Automation or Scheduled Task, or to run ad-hoc.

Import New Scripts:

1. Navigate to Administration > Library > Automation. Then, click Add > Import from file or Import from template in the top right corner.

Import New Scripts

2. Select the file for the script you wish to import. If you want to import from template, NinjaOne offers a number of native scripts out-of-the-box in the Template Library that you can choose from.

3. Fill out the information in the pane on the right side and then click Import in the top right corner.

Add Automated Applications: Installation

To install an application automation:

1. Navigate to Administration > Library > Automation. Then, click Add > Installation in the top right corner.

Navigate to Administration > Library > Automation.

2. Use the table below to help fill in the fields. Use the Additional Settings tab at the top of the page to see more configuration options.

Field Description/Action
Name Give the application a unique identifier.
Operating System Select whether the application is to run on Mac or Windows devices.
Architecture Select whether the application is to run as 32-bit, 64-bit, or both.
Note: Mac can only run on 64-bit.
Installer Use the drop-down to select whether to upload the installer or provide the path to the MSI or EXE by using a HTTPS URL. Mac installers use PKG and DMG.
Important Note: There is a file upload size limit of 1GB. If the installer takes more than 30 minutes to upload, it will time out and you must try again.
Categories (Mandatory) Select one or more categories that best describe what the application is used for.
Run As Both Mac and Windows allow the application to run as the system. Depending on the OS selected, you may have additional options to run as the current user or utilize the preferred Windows local or domain admin credentials from your credential store.
Important Note: Some software may require the install to be deployed with specific credentials.
Parameters When adding preset parameters, click Add located in the top right of the Parameters field. If the installer requires a specific silent parameter, this where it should be added. For more information about preset parameters, please see Automation Library: Parameters.
Important Note: MSI installers are automatically run with the following parameters:

  • /quiet /qn /norestart /log {path to our script folder}ninjascript-output-{current-time}.txt
  • Examples of common EXE silent parameters: /silent /Silent /S /s -silent –silent
  • Examples of common MSI silent parameters: /quiet /qn /q

Additional Settings

Helper Files Helper files can be included with the installer—an example of a helper file might be a license file you need to deliver with a software installation.
You can add up to five files at 100MB each.
Installer Icon Choose to display a custom icon within the NinjaOne console for the application (this icon only appears in the Automation Library, not on the devices).
Pre-script Choose an installed custom automation from the library to run before the installed application. Native scripts are not available for this purpose.
Post-script Choose an installed custom automation from the library to run after the installed application. Native scripts are not available for this purpose.

Additional Settings 

3. Click Submit. If there are any errors or failures when attempting to add the application, the affected fields turn red and display an exclamation point icon. Hover your mouse pointer over the icon to see the reason for failure.

Additional Settings 

The application moves to the Under Review tab where the system validates it to ensure both the main and helper files are free of malware or viruses, and only displays under Automations after the scan is successful.

Modify, Copy or Delete Existing Scripts/Applications:

Important Note: Only custom scripts and applications can be modified, copied, or deleted. NinjaOne’s native scripts cannot be deleted, and only the category can be edited. Run/Install applications can be deleted or edited but cannot be copied. Old style installers are not editable—they can be only deleted or viewed.

1. Navigate to Administration > Library > Automation and hover your mouse pointer over a script or application; click the ellipsis button. Optionally, use the Type dropdown to filter out native scripts.

Modify, Copy or Delete Existing Scripts/Applications: 

2. Click Edit to open up the script editor or click Delete to remove the script/application from your library.

Important Note: If you delete a category, the scripts that were in the deleted category will be moved to “Uncategorized”.

NinjaOne also has a feature that lets you create a copy of a native script by importing from the script library and modifying them for your specific purposes.

3. Select Copy to create a new script identical to the original script. You will be prompted to set a name for the new script. Click Save to finalize the new script.

Benefits, Strategies and Best Practices for Script Library with NinjaOne

Leverage Pre-Built Scripts: NinjaOne Script Library likely provides pre-built scripts for common tasks. Customize these as needed to fit your specific requirements.

Utilize Variables and Parameters: Use variables and parameters to make your scripts more flexible and adaptable to different scenarios.

Consider Error Handling: Implement error handling mechanisms to gracefully handle unexpected situations and prevent script failures.

Document Your Scripts: Provide clear documentation to explain the purpose, inputs, and outputs of your scripts for future reference and maintenance.

FAQ

A script library is a place where you can find examples of code called “scripts.” These scripts can be added to things like dashboards to make them more useful. It also has ready-made scripts to automate IT tasks. These scripts might help with things like installing software, updating programs, and backing up data.

Automation scripts are pre-written instructions that computers can follow to do tasks automatically. These instructions are usually written in a special language like Python, Bash, or PowerShell. Using automation scripts can help businesses work more efficiently and productively. By having computers do routine tasks, businesses can free up their employees to work on more important things.

You can create a reusable template to automate deploying multiple applications using scripts. Policies will automatically fill this template, trigger deployments, and ensure full automation. NinjaOne’s automation streamlines software deployment, improving IT efficiency. Refer to the Software Deployment User Guide for more details. Check out this link about scripting: IT Automation Scripts: Definition & Overview | NinjaOne

NinjaOne allows you to write and deploy scripts in common languages you already know, including Powershell, Batch, ShellScript, Javascript, and VBScript. You can check this link for your reference: Remote Script Deployment | NinjaOne

×

See NinjaOne in action!

By submitting this form, I accept NinjaOne's privacy policy.