Skip to main content

NinjaRMM Deployment - [Windows]

Summary

This script deploys the NinjaRMMAgent to Windows-supported OS, based on the article provided below: Agent Installation Tokenization. It depends on the Authorization token, which will be kept in the company or site custom fields.

Sample Run

Sample Run 1

Sample Run 2

Dependencies

CW RMM - Ninja Migration Custom fields

Group - Ninja RMM Deployment

Solution - CW RMM to Ninja Migration

Task Creation

Script Details

Step 1

Navigate to AutomationTasks
step1

Step 2

Create a new Script Editor style task by choosing the Script Editor option from the Add dropdown menu
step2

The New Script page will appear on clicking the Script Editor button:
step3

Step 3

Name: NinjaRMM Deployment - [Windows]
Description: This script deploys the NinjaRMMAgent to Windows-supported OS, based on the article provided below: https://ninjarmm.zendesk.com/hc/en-us/articles/27524794230669-NinjaOne-Agent-Installation-Agent-Tokenization. It depends on the Authorization token, which will be kept in the company or site custom fields.
Category: Application

Script Detail

Script Editor

Click the Add Row button in the Script Editor section to start creating the script
AddRow

A blank function will appear:
BlankFunction

Note: Limit all the function to Windows machines.

Windows Limit

Row 1 Function: Pre-defined Variable

Select the Pre-defined Variable and provide the details and click on Save.

Variable: Deployment

Custom Field: Ninja Deployment Enable

Set Pre-defined 1

After clicking on Save the Pre-defined will show data as:

Deployment Enable

Row 2 Function: Pre-defined Variable

Select the Pre-defined Variable and provide the details and click on Save. Make sure to select the Ninja Deployment Exclude site level custom field.

Variable: DeploymentExL

Custom Field: Ninja Deployment Exclude

Pre-defined 2

After clicking on Save the Pre-defined will show data as:

Deployment Exclude

Row 3 Function: Pre-defined Variable

Select the Pre-defined Variable and provide the details and click on Save. Make sure to select the Ninja Deployment Exclude endpoint level custom field.

Variable: DeploymentExC

Custom Field: Ninja Deployment Exclude

Pre-defined 3

After clicking on Save the Pre-defined will show data as:

Deployment Exclude

Row 4 Function: Pre-defined Variable

Select the Pre-defined Variable and provide the details and click on Save.

Variable: OrgID

Custom Field: Ninja_Org_ID

Pre-defined 4

After clicking on Save the Pre-defined will show data as:

Org ID

Row 5 Function: Pre-defined Variable

Select the Pre-defined Variable and provide the details and click on Save.

Variable: LocID

Custom Field: Ninja_Site_ID

pre-defined 5

After clicking on Save the Pre-defined will show data as:

Loc ID

Row 6 Function: PowerShell Script

Search and select the PowerShell Script function.

Select PowerShell

PowerShell Selected

The following function will pop up on the screen:

Empty PowerShell Editor

Paste in the following PowerShell script and set the Expected time of script execution in seconds to 900 seconds. Click the Save button.

PowerShell Script

PowerShell Script

Row 7 Logic: If/Then

Logic If/Then Logic Selected

Row 7a Condition: Output Contains

In the IF part, enter An error occurred in the right box of the "Output Contains" part.

Condition

Row 7b Function: Set Custom Field

Add a new row in the IF part by clicking the Add Row button.

Add Row 1

Search and select the Set Custom Field function.

Select Custom field 1

Search and select Ninja Deployment Result in the Search Custom Field field, set Failed in the Value field, and click the Save button.

Custom field 2

Custom field 3

Row 7c Function: Script Exit

In the IF part, add a new row by clicking on the Add row button.

Add Row 3

In the script exit message, simply type The Ninja deployment failed. Refer to the logs: %Output%

Script Exit

Row 8 Function: Script Log

Add a new row by clicking the Add Row button after END IF

Add Row 5

Search and select the Script Log function.

Script Log Empty

The following function will pop up on the screen:

Script Log Empty 1

In the script log message, simply type %Output% and click the Save button.

Script Log Message

Row 9 Function: Set Custom Field

Add a new row by clicking the Add Row button.

Add Row 7

Search and select the Set Custom Field function.

Select Custom field 5

Search and select Ninja Deployment Result in the Search Custom Field field, set Success in the Value field, and click the Save button.

Custom field 6

Custom field 7

Save Task

Click the Save button at the top-right corner of the screen to save the script.
SaveButton

Completed Task

Complete Task

Deployment

This task is required to be deployed using a dynamic group.

It can be scheduled to run every 1 hour. Follow the below deployment step to schedule it.

  • Go to Automation > Tasks.

  • Search for NinjaRMM Deployment - [Windows]

  • Then click on Schedule

Schedule Task

Target Set

  • Click Device Group -> Search for Ninja -> Select Ninja RMM Deployment group and click save selection

Target select

  • Click on Schedule option, and set the time and click on Repeat to set it to run every hour

Repeat

Schedule Task

Output

  • Custom field
  • Script Log

Changelog

2025-04-30

  • Initial version of the document