Run Scripts Remotely
With Action1, you can assist your colleagues by running scripts remotely on multiple managed endpoints: PowerShell or Cmd scripts on Windows machines, and Bash scripts on macOS machines.
To run a script on remote endpoints:
- Navigate to the Endpoints page.
- Select one or several endpoints where you want to execute a script and click Run Script. You can also select this option from the endpoint’s Actions.
Alternatively, navigate to Automations, click New Automation, and from the list of actions select Run Script. For more information, see Automation with Action1.
On the Run Script step:
- Enter the script content or select a script from the (Script Library).
- If necessary, specify the script parameters – for example, a message to be displayed to device owners.
- The script shall exit with exit code 0 on success or with a non-zero exit code if it encounters any errors. You can instruct Action1 to initiate a reboot if the script returns any of these exit codes.
- Select the Script language. The following languages are supported:
- PowerShell, Cmd – for Windows
- Bash – for Mac
TIP: If you are adding a new script, it is recommended that you click Save in Script Library for future reuse.
- If you need the target endpoint to address some condition before running the main script (for example, make sure it was rebooted within the last 30 days), you can run a condition script:
- Action1 will run this script before the main script.
- If the condition script exits with the code other than 0 (meaning that the condition was not met, and target endpoints are non-compliant), then Action1 will run the main script.
- The main script will bring the endpoint into compliance (for example, force the reboot if the number of days is more than 30).
To implement such course of action, select Execute the script above only if the automation condition script returns a non-zero error code. Provide a condition script, specify its language and exit codes.
- Specify whether to reboot the target endpoint. You can also instruct Action1 to show a message to the endpoint users and give them time to save their work, and set the message timeout.
If I select to reboot, how will this affect the endpoint users?
- Logged-in Users: If a user is logged in, even through a non-interactive session (such as a remote terminal server session), Action1 will show a reboot prompt in that user’s logon session. This provides an opportunity for the user to postpone the reboot, up to the maximum time configured in the Action1 policy settings.
- Locked Sessions: If the session is locked, the reboot prompt will still be displayed. The user will see this prompt immediately upon unlocking their session.
- Multiple Users: In scenarios where multiple users are logged in, each will receive their own reboot prompt within their logon sessions. Any one of these users can permit the reboot to proceed; it doesn’t require approval from all users.
- No Users: If no one is logged in, Action1 will proceed to reboot the system immediately without displaying any prompts.
On the Select Endpoints step:
- Check the list of target endpoints.
- To include more targets, click Add Endpoints. You can pick endpoints individually or select an entire endpoint group.
On the Schedule step:
- Enter the automation name.
- Select when to run this automation.
- You can configure the automation to Run once – with any of these options:
- Run now
- At specified time, where you should select the required date, time, and timezone.
- Alternatively, you can schedule the automation to run periodically:
- Every N hours, starting from the selected date and time.
- Weekly – every week on the selected day, for example, every Sunday at 01:00 AM (local endpoint time).
- Monthly – every month on the specified day, for example, on the first day of every month at 11:30 PM (current timezone).
- You can configure the automation to Run once – with any of these options:
- In the Missed schedule retry and maintenance window section, specify the Automation completion deadline after the scheduled start time.
This will instruct the offline or disconnected endpoints to retry the automation once they come online within the specified timeframe.
How this parameter works?
This parameter instructs the offline or disconnected endpoints to retry the automation once they come online within the specified timeframe. The automation will be terminated if it exceeds this deadline.
Example configuration:
- Automation is scheduled to run at 2 am
- The deadline/maintenance window is set to 8 hours
Endpoint: | Powered on at: | The automation will… |
A | 8 am | … start at 8 am, complete by 10 am |
B | 12 pm | … not start |
C | 2 am (online at scheduled time) | … start at 2 am, complete by 10 am |
NOTE: If you need to update this setting, make sure not to set the time frame to an interval longer than the frequency of action execution (that is, do not set it to 48 hours if the action is executed every day).
- Once ready, click Finish.