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

NinjaOne Endpoint Management: Native Automation Scripts

Topic

The NinjaOne console provides native automation scripts that you can deploy to your managed devices. This article describes the functions of the scripts included with your NinjaOne subscription.

Environment

  • NinjaOne Automation Library
  • Microsoft Windows
  • Apple macOS
  • Debian Linux

Description

The Automation Library provides automation scripts that you can run on devices ad hoc, on a schedule, through policy conditions, or with a scheduled task. In addition to NinjaOne's native scripts, you can access additional templates via the Automation Template Library. Find related articles in our Additional Resources section. 

Native Script Categories

Some scripts may be compatible with multiple operating systems. NinjaOne organizes each native script by category, which you can view in the Categories column. 

You can create new categories in the Categories tab and add them to the native scripts by clicking the script and selecting the new category from the drop-down menu. 

automation library_categories.png
Figure 1: Automation library script categories
You must enable permissions for technicians to create, view, update, or delete categories, and grant them the necessary permissions to run scripts for these categories. To learn more, refer to User Permissions: Permission Options.

Native Script Descriptions

Select your operating system (OS) to learn about the scripts we offer: 

Apple macOS Native Scripts

The following tables provides a description of each native script for macOS devices. 

Script NameDescription and Requirements
Disable Mac SleepThis script sets a macOS system to never sleep.
Disable/Enable ARD (Apple iOS Remote Desktop)This script disables or enables ARD (Apple Remote Desktop) through the use of the kickstart command-line utility.
Disable/Enable SSH (Secure Shell)This script disables/enables SSH. For Mac, this is done through use of the systemsetupcommand-line utility.
Disable/Enable VNC (Virtual Network Connection)This script disables or enables VNC through the use of the kickstart command-line utility.
Download updates, don't installThis script triggers the macOS update mechanism locally on the machine to download any available updates (but not install them yet).
Empty TrashThis script empties the trash for each user on the device.
Enable Wake-on-LANThis enables Wake-on-LAN capabilities through use of the systemsetupcommand-line utility.
Flush DNSThis script clears the DNS cache using different command-line utilities dependent on OS version.
Install all available patches This script triggers the update mechanism locally on the machine to download and install all available patches.
Install all available patches, restart if requiredThis script triggers the update mechanism locally on the machine to download and install all available patches. If a reboot is required following the installation, it then reboots the machine.
This script is only compatible with devices running macOS High Sierra and above.
Install only recommended patches This script triggers the macOS update mechanism locally on the machine to download and install only the recommended (as classified by Apple) patches.
Install only recommended patches, restart if required (requires 10.13.4 or newer)This script triggers the macOS update mechanism locally on the machine to download and install only the recommended (as classified by Apple) patches and then reboots the machine if a reboot is required following the install.
This script is only compatible with devices running macOS High Sierra and above.
Kill Core AudioThis script resets the audio services daemons.
List all available patchesThis script queries the update mechanism locally on the machine to provide a list of all available patches. The list will then be visible in the Activity table.
If no available patches are found upon running this script, the "Action: Completed" entry in the Activity Feed will simply state "Finding available software" (with no actual patches listed).
OS patch applyThis script applies available operating system updates.
OS patch scanThis script triggers a scan for operating system updates.
Purge Disk CacheThis script clears the disk cache using the purge command-line utility.
Reapply user permissionsThis script runs chown and chmod commands for all users.
Reboot This script will reboot a device.
This script uses the shutdown command line utility to force a reboot.
Repair Disk PermsThis script runs repair disk permissions on "/".
Repair SSHThis stops SSH (secure shell) connections and reinitializes the SSH daemon.
Repair TeamViewerThis script reinitializes TeamViewer, stops the service, and restarts it.
Reset Launcher ServicesThis script resets launch services. For more information, refer to the launch services database (external).
Reset Printing

This script performs the following actions:

  • restarts or resets cupsd
  • resets printer plists
Turn Automatic Updates OffThis script sets the AutoUpdateRestartRequired setting in Preferences to "FALSE".
Wake Display UpThis script wakes the display through the use of the pmset command-line utility.

Microsoft Windows Native Scripts

The following table provides a description of each native script for Windows devices. 

Script NameDescription and Requirements
Clear DNS CacheThis script runs the following command: IPCONFIG /FLUSHDNS.
Clear Event LogsThis clears out all backup and security event logs for all users.
Defrag This runs hard drive defragmentation on the endpoints. You can exclude the boot volume or the recovery volume.
Delete Temporary Files

This script deletes temporary files in the following locations (when the location is not locked):

  • %WINDIR%Temp
  • [PROFILES_DIRECTORY (c:users, c:documents and settings, others]
  • [USERNAMEFOLDER]AppDataLocalTemp
  • [PROFILES_DIRECTORY (c:users, c:documents and settings, others]
  • [USERNAMEFOLDER]Local SettingsTemp
Disable/Enable CD-ROM DrivesThis toggles a registry key to disable/enable the respective drives. Depending on the OS, some machines may require a reboot to ensure this change is enforced.
Disable/Enable Floppy DrivesThis toggles a registry key to disable or enable the respective drives.
Disable/Enable USB DrivesThis script disables/enables the use of USB storage devices through a registry setting.
Disable/Enable User Access ControlThis toggles the following registry key with a value of "1" (enable) or "0" (disable):
SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
Enable UAC uses "1" as a value (0x00000001) which is not a return to the windows default ("5" / 0x00000005)
Empty Recycle BinThis allows you to run "empty recycle bin" on all drives or for all users on the corresponding endpoints for Windows 7 and newer.
This script does not refresh the folder, so the icon may still show "full" until the recycle bin is refreshed.
Fix File System ErrorsThis script runs the following command: CHKDSK /R
Once this option is selected, you will need to schedule a reboot for this action to finish running.
Fix rebuild performance countersThis runs a script to clear and rebuild performance counters.
Forced RebootThis script utilizes WINAPI (Windows application programming interface) to run the InitiateSystemShutdown command with the forced parameter and executes after 5 seconds.
Group policy force updateThis runs the following command: gpupdate /force
Log Off Current UserThis script allows you to log out all logged-in users from an endpoint.
OS patch applyThis script applies available operating system updates.
OS patch scanThis script triggers a scan for operating system updates.
Reboot This script will reboot a device.
This script utilizes WINAPI to run the InitiateSystemShutdown command without the forced parameter and executes after 30 seconds.
Reboot (pending reboot devices) This script utilizes WINAPI to run the InitiateSystemShutdown command and will only run on devices that have a pending reboot at the time when the script is run.
Release & Renew IP AddressThis runs the following commands: IPCONFIG /RELEASE and IPCONFIG /RENEW.
Removable MediaThis script allows you to disable or enable the use of USB, CD-ROM, and Floppy drives through a registry setting.
Remove Google/Yahoo toolbarFor these scripts, NinjaOne reads the uninstall key and then runs the uninstall string.
Run Windows CleanupThis runs the Windows Disk cleanup tool with the option /SAGERUN:1 
The full command is: (CLEANMGR /SAGERUN:1)
Refer to cleanmgr | Microsoft Learn (external) and Automating Disk Cleanup tool - Windows Server | Microsoft Learn (external) for more information. 
SFC ScannowThis script triggers an SFC (System File Checker) scan as the currently logged-in user. This requires Vista or greater OS, and a user with admin permissions must be logged in to the device.
System RestoreThis script toggles the registry key to 0 or 1 to enable/disable the ability to perform a system restore.
The registry key that is responsible for system restore is: 
HKEY_LOCAL_MACHINESOFTWAREPoliciesMicrosoftWindows NTSystemRestore
Windows ServiceThis allows you to start or stop a Windows service.
The list of services in the dropdown menu is created by cumulating all the services from all devices within your NinjaOne environment, so it’s a superset of all the services for the devices in your environment.

Ubuntu Linux Native Scripts

The following table provides a description of each native script for Linux devices. 

Script NameDescription and Requirements
Disable/Enable SleepThis script sets the Linux system to never sleep or enables the system to sleep.
Disable/Enable SSH (Secure Shell)This script disables/enables SSH. For Mac, this is done through use of the systemsetup command-line utility.
Empty TrashThis script empties the trash for each user on the device.
Flush DNSThis script clears the DNS cache using different command-line utilities dependent on OS version.
Force logoutThis script forces logout for the currently-logged-in user.
Install all available patches This script triggers the update mechanism locally on the machine to download and install all available patches.
Install all available patches, restart if requiredThis script triggers the update mechanism locally on the machine to download and install all available patches. It then reboots the machine if a reboot is required following the install.
Install only security patchesThis script triggers the update mechanism locally on the machine to download and install only the security (as classified by Linux) patches.
Install only security patches, restart if requiredThis script triggers the update mechanism locally on the machine to download and install only the security (as classified by Linux) patches and then reboots the machine if a reboot is required following the install.
List all available patchesThis script queries the update mechanism locally on the machine to provide a list of all available patches. The list will then be visible in the Activity table.
If no available patches are found upon running this script, the "Action: Completed" entry in the Activity Feed will simply state "Finding available software" (with no actual patches listed).
List only security patchesThis script queries the update mechanism locally on the machine to provide a list of all available security patches. The list will then be visible in the Activity table.
If no available patches are found upon running this script, the "Action: Completed" entry in the Activity Feed will simply state "Finding available software" (with no actual patches listed).
OS patch applyThis script applies available operating system updates.
OS patch scanThis script triggers a scan for operating system updates.
Reboot This script will reboot a device.

Additional Resources

Use the following resources to learn more about automation in NinjaOne: 

FAQ

Next Steps