Scripting Basics

Scripting is one of the core RMM features in Syncro. It was designed to have maximum flexibility and interoperability with tools you already use.

In Syncro Scripting you can use .bat files, powershell, and vbscript. Powershell is the primary and most supported because of its power and relative ease of readability for technicians over vbscript.

Scripting Deep Dive Video

File Type

  • Powershell - Microsofts awesome scripting language for Windows administration. We highly recommend you use this!
  • Batch - You probably have a few .bat files laying around, these are common and do work - but leave a lot to be desired in automation.
  • VBScript - Super powerful, but very hard to write unless you are a programmer - we support them but we won't often help with them.
  • Mac Bash - A Unix shell and command language available for sending commands to Mac assets.

Run As

You can choose to have the script run as "system" (like in a background service with system level access) or you can run as "current user'.

Current User only works if they are currently logged in! For most system maintenance and alerting you want to choose "system". Only use "current user" if you need to know something about a logged in user or you want to alert them/etc.

Required Files (Uploads/Attachments)

You can upload any file and "require" it in your script. It will download and be where you requested (Destination File Name) before the script actually runs.

 

When utilizing this file within the script, you'll want to be sure that, after clicking Add a Required File, you enter the full path when filling in the Destination File Name field, including the file name itself. For example, if the name is "script.bat", you could have the path be something like "C:\Users\syncro\script.bat" into the Destination File Name field.

We have some examples in our library where you can run Bleachbit tools, or Techsuite tools. (coming soon).

 

Syncro Powershell Module

THIS is where the main power comes from. Of course Powershell is fantastic by itself, but with our custom "module functions" we've added you can do some really cool stuff.

Functions

"Rmm-Alert" - Can be used to trigger an ad-hoc custom RMM Alert into the PSA. For example you could write a script to check hard drive space, if it's below % it could trigger an RMM Alert in Syncro which would tie into the dashboard and trigger a notification. This can be hooked into anything you can possibly script in Powershell, which is a lot. (Event viewer, WMI, and on and)

"Display-Alert" - Can popup a message for the currently logged in user. Must be used with a scripting running as "current user"

"Get-ScreenCapture" - Will save a screenshot to the filename you specify. Great to use in conjunction with Upload-File (coming soon)

"Send-Email" - Powershell has SMTP Email already, but you have to add an smtp server. Our Send-Email function just uses our API and doesn't need anything special but internet access.

You can find the actual documentation for these functions on the Script Edit page where it will be most useful.

Script Return Values (Success/Failure/Error)

When you run a script, you can tell Syncro if it was successful, failed, or had an error. You'll see this after running a script here:

Success indicator

Syncro relies on the Exit Value of the script to determine the outcome. You'll need to write these into your scripts.

Exit 0 = Success

Exit 1 = Error

Exit 2 or higher = Failure

 

Scheduling and Bulk Operations

Our scripts can currently be run one-off from the "RMM Hover", from the Assets list page in bulk (check many assets and click Manage, Run Script), and also scheduled to run on a recurring schedule.

A best practice is to not have a script run too often because while it's running another operation cannot run. If you have too many long running scripts running they can start to get backed up in a queue. We suggest scheduled scripts to be daily if possible, but many schedule options are available down to every 15 minutes.