Already a NinjaOne customer? Log in to view more guides and the latest updates.

Using Command Line Interface (CLI) in NinjaOne

NinjaOne's Command Line Interface (CLI) is a robust tool that provides much of the same functionality and visual experience as running cmd.exe on Windows or Terminal on macOS. You can also launch PowerShell remotely on Windows devices.

To learn more about the ninjarmm-cli component for Windows, Mac, and Linux devices and interacting with custom fields, refer to Command Line Interface (CLI): Custom Fields and Documentation Scripting.

Select a topic to continue:

Granting CLI Permissions

System administrators have access to the CLI by default. For other technician roles, or technicians without roles, you must manually grant CLI permissions.

  1. In NinjaOne, navigate to Administration → Accounts → Technician roles and select a technician role.
CLI_NavToR_TechRomes.png
Figure 1: Technician role settings page, showing the navigation path Administration → Accounts → Technician roles (click to enlarge)
  1. Navigate to Devices → Remote tools, then click the Allowed drop-down menu and select the Command Line checkbox. When finished, click Save changes.
CLI_Devices_CommandLinePermish.png
Figure 2: Devices → Remote tools → Allowed (click to enlarge)

Using Utility Icons

The Icons in the CLI, PowerShell, or Terminal window's navigation menu allow you to perform the following actions on the device:

  • Keyboard icon: allows you to send the "Ctrl+C" command to terminate the current action.
  • Disk icon: allows you to download Terminal contents to a txt file.
  • Duplicate icon: allows you to copy the contents to clipboard.
  • "X" icon: terminates cmd.exe on the device.
CLI_Icone.png
Figure 3: CLI utility icons (click to enlarge)

Using CLI or PowerShell on a Windows Device

Launching CLI or PowerShell

To launch PowerShell from NinjaOne, it must be installed locally on your device. CLI access is not available if the device is offline.

  1. On the device's Overview page, place your cursor over the Remote CLI icon.
  2. Select CMD or PowerShell from the drop-down menu, then select the appropriate System (localsystem) or Logged-in user run type when the options appear. Click the icon next to your choice to open the session in a new tab.
CLI_LaunchCLI_Windows.png
Figure 4: Windows device overview → Remote CLI icon and launch options (click to enlarge)
Because the logged-in user context runs like an elevated Administrator command prompt, commands such as net use will not see mapped drives that were mapped in a standard user context.

Windows CLI Tool Functionalities

The CLI tool includes the following functionalities:

FunctionalityDescription
Run interactive shellsRun any interactive shell installed on the PC, including cmd.exe, powershell.exe (or pwsh.exe), bash.exe, psql.exe, python.exe, and others.
Execute scripts inside shellsCopy and paste scripts to powershell.exe, bash.exe, or python.exe; copy and paste SQL to psql.exe.
Run WSLRun and use WSL (Windows Subsystem for Linux) to access a Linux distribution installed under Windows.
Install and uninstall softwareUse Chocolatey to install and uninstall software on the PC. Refer to Chocolatey.org (external link) for more information.
Work with shells in full interactive mode

Work with all shells in full interactive mode with all events and pseudo-GUI support, including:

  • Running and displaying Far Manager
  • Using Ctrl+C to stop execution of the current task (use Shift+Ctrl+C to copy; use Shift+Ctrl+V to paste).
  • Using mouse clicks, mouse scroll, arrow keys, and hotkeys (F1–F10) for Far Manager and other pseudo-GUI apps.

CLI Considerations

  • Highlighting any text in the CLI utility automatically copies to the clipboard.
  • While running cmd.exe as System, SFC commands will not resolve on a user level (we do include a sfc /scannow command in our native scripts. Refer to NinjaOne Endpoint Management: Native Automation Scripts for more information).
  • To use a curl command, you must use the -O flag.
curl -O https://url.zip
  • To use wget, use the --no-check-certificate --progress=bar:force parameter at the end of your URL.
wgethttps://url/somefile.zip--no-check-certificate --progress=bar:force

Launching the CLI (Terminal) on a Mac or Linux Device

To view the files and folders under ~/Users/ within the remote Terminal, you must grant Full Disk Access to the ninjarmm-macagent file (which is housed in the hidden NinjaRMMAgent folder under /Applications). This can be done locally on the machine under System Preferences → Security & Privacy → Privacy.

Launching the CLI (Terminal)

CLI is not available if the device is offline.
  1. On the device's Overview page, place your cursor over the Remote CLI icon, select CMD or PowerShell from the drop-down menu, then select the appropriate System (localsystem) or Logged-in user run type when the options appear.
  2. Choose whether to launch Terminal, or Terminal as Root. Click the icon next to your choice to open the session in a new tab.
CMD_LaunchCLI_macOS.png
Figure 5: macOS device overview → Remote CLI icon and launch options (click to enlarge)

Additional Terminal Launch Options

In addition to using the device's Overview page, you can:

  • Launch a command line session from a global search.
  • Launch a command line session from the Organization dashboard.

Launching the CLI or Terminal from a Global Search

To launch the CLI or Terminal from a global search:

  1. In NinjaOne, enter the device name into the search bar.
  2. Place your cursor over the device name in the search results, then click the Run icon when it appears.
  3. Select your connection type from the drop-down menu:
    • Windows: Select CMD or PowerShell, then select the appropriate run type when the options appear. Click the icon next to your choice to open the session in a new tab. Refer to the Using CLI or PowerShell on a Windows Device section of this article for more information on connection types.
    • macOS or Linux: Select Terminal, then select Terminal as Root or Terminal when the options appear.
CLI_LaunchFormSearch_Windows.png
Figure 6: Global search result → Run icon → launch options (click to enlarge)

Launching the CLI or Terminal from the Organization Dashboard

To launch the CLI or Terminal from the organization dashboard:

  1. In the organization's Overview page, select the device, then click the Run icon when it appears.
  2. Select your connection type from the drop-down menu:
    • Windows: Select CMD or PowerShell, then select the appropriate run type when the options appear. Click the icon next to your choice to open the session in a new tab. Refer to the Using CLI or PowerShell on a Windows Device section of this article for more information on connection types.
    • macOS or Linux: Select Terminal, then select Terminal as Root or Terminal when the options appear.
CLI_LaunchFromOrg.png
Figure 7: Organization dashboard → Run icon → launch options (click to enlarge)

Additional Resources

For a list of frequently asked questions about CLI, refer to Command Line Interface (CLI): FAQ.

FAQ

Next Steps