Remote PowerShell / Bash Script Execution
PowerShell script can be executed:
With enabled RMM Service management mode and 2FA, you can run PowerShell scripts remotely from Management Console on computers with RMM Agent installed.
As of RMM Agent 2.O the interactive terminal for script execution is introduced.
For the previous versions starting from RMM Agent 1.6, the following script execution features are supported:
- Exit codes
- Script errors displayed
- Copy and paste
- Script interruption
RMM Agent script execution has some limitations:
- PowerShell version 5.0 or later is recommended. PowerShell version 4.5 can be used, but with restrictions:
- Once a command or script are executed, results of the previous command/script become not available
- Two-factor authentication must be enabled in your account
Run PowerShell Scripts on Remote Computer
To use a PowerShell console or to upload a PowerShell script to execute on a remote computer, proceed as follows:
- Open the Management Console.
- On Computers select Remote Management if you use legacy main menu, or open RMM > Computers page in the new main menu.
- In the computer list, find the target computer, then in the RMM column click the diagram icon.
- As the computer info is loaded, switch to the PowerShell tab.
- Select the tab to perform the required operation:
- Script Library. Select one of predefined or added by you scripts from RMM Script Library.
- Script Code. Select this option to type script code for remote computers.
- Upload File. Select this option to execute PowerShell or Bash script on selected remote computer from selected file. Click + to upload the PowerShell script to selected computers.
- Once the script is selected, created, or uploaded, click Execute.
- Confirm with 2FA.
- Wait while the script execution is complete to retrieve the result.
Note that PowerShell scripts are run by the 'System' account
Script Library
You can select one of predefined or added by you scripts from RMM Script Library.
Select Category of script, then select the script in this category. Click Execute. Confirm the action with Two-Factor Authentication verification code.
Click Last executed script result to see the result of the script execution. Consider, some scripts take a while to be completed.
Upload File
You can execute PowerShell or Bash script on selected remote computer from selected file. Click + to upload the PowerShell script to the remote computer.
Drag and drop script file to the upload area. Click Execute. Confirm the action with Two-Factor Authentication verification code.
Click Last executed script result to see the result of the script execution. Consider, some scripts take a while to be completed.
Terminal
You can execute PowerShell or Bash script on selected remote computer in a terminal.
You can maximize the terminal tab for more convenient experience.
Confirm the action with Two-Factor Authentication verification code.
Run PowerShell Scripts on Multiple Computers
You can run PowerShell scripts remotely on multiple computers with the RMM Agent installed.
To run PowerShell scripts on multiple computers from a file or from script library, proceed as follows:
- Open the Management Console.
- On Computers select Remote Management if you use legacy main menu, or open RMM > New Group Acrion Task page in the new main menu.
- RMM Group Action wizard starts.
- Select the PowerShell Script group action.
Click Next.
- Select computers to execute the script
Select a scope to apply the group action. You can apply group action to all your companies, to specific companies, or to specific computers. You can exclude specified computers from the group action or use tags to aply tqask to the computers with selected tags.
Consider, group actions apply only to computers with the RMM Agent installed and Monitoring enabled. To apply these actions to other computers, install RMM Agent instances onto these computers first. You can select computers that are offline at the moment of selection. The action, in this case, will be applied as these computers come online. Click Apply to save your selection.
Click Next.
- Select the tab to enter PowerShell script to execute:
- Script library. Select one of predefined or added by you scripts from RMM Script Library.
- Upload File. Select this option to execute PowerShell or Bash script on selected remote computer from selected file. Click + to upload the PowerShell script to the remote computer.
- Terminal. Select this option to open PowerShell Terminal for the remote computer.
Once the script is selected, click Next.
- Specify the schedule for the script execution. If you plan to run the execution manually, select the No schedule (run manually) option.
Click Next.
Note that if you select the 'No schedule' option, the started group action can be immediately applied to computers that are offline at the moment of the group task creation as they come online. Check whether the the Run missed scheduled tasks immediately when computer starts up option is selected to perform it.
If required, set the schedule for the group action execution. You can set the following schedule options:
- Run once
- Specific date (once, daily, or monthly). You can create a requrring schedule. The recurring schedule can be used for a task that takes place on a regular basis (e.g., every Monday and Wednesday from October through December on specific weekday and time).
When you specify the time for the group action execution, remember that the system time of the instance the RMM Agent is installed will be used
Note that PowerShell scripts are run by the 'System' account
Once you complete the new group action task configuring, click Create. You will be promplted to confirm the task execution.
Confirm the group action according to selected 2FA verification method.
If you selected the Run Once option, you will be provided with the report of the group task execution in real-time.
You can view the results of the group task executions on RMM > RMM Group Actions.
Script Library
You can select one of predefined or added by you scripts from RMM Script Library.
Select Category of script, then select the script in this category.
By default, the script execution is tracked during 5 minutes to display the result of the script execution in the task. Some scripts take a while to be completed. You can change the tracking timeout , if necessary.
Script Code
You can type script code here to execute.
By default, the script execution is tracked during 5 minutes to display the result of the script execution in the task. Some scripts take a while to be completed. You can change the tracking timeout , if necessary.
Upload File
You can execute PowerShell or Bash script on selected remote computer from selected file. Click + to upload the PowerShell script to the remote computer.
Drag and drop script file to the upload area.
Manage Group Action Tasks and View Results
With new main menu click RMM > Group Action Tasks to see RMM Group Action Task info.
To view the group task details, click the task name in the Task column.
The following actions are available:
- To run the task now, click the action menu to the right of the task to run, then click Run Now.
- To edit the task, click the action menu to the right of the task to change, then click Edit.
- To delete the task, click the action menu to the right of the task to delete, then click Remove.