Powershell - Execute a Script Remotely

Script that will run a script on a remote PC or server then the return code from the remote script


Description

This is a powershell script that will run a script on a remote PC or server then the return code from the remote script will be returned to the local machine as a parameter.

This is very useful when you want to run something on a remote machine but also need a return code as there may be dependencies on the outcome of the remote script.

  • The script can take parameters which are passed into the command for remote running

  • The return code is the return code of the remote session so the remote script should exit with an appropriate exit status so that the correct return code is picked up (see example file test.txt which exits with a status 2)

  • As the return code is a local variable it can be used locally for other purposes such as the exit code of a Uproc


Requirement

This script requires:

  • Powershell

  • WinRM configured to allo remote execution


Use

This script need 2 parameters:

  • -my_remote_pc: Hostname or IP of the remote computer

  • -remote_run: Script to execute on the remote computer


Target environments: Windows (all versions)


Prerequisites: Powershell should be installed on the windows PCs. For remote running adequate security is required to allow a user on one PC to run remote code on another. Credentials can be passed by the script however its never a good idea to hardcode passwords into scripts so the security is better taken care of elsewhere.
No content available.
No content available.
Please log in using your Broadcom account to download this plugin.
Please log in using your Broadcom account to download this plugin.
Products Workload Automation, Dollar Universe Workload Automation
Versions 5.x, 6.x
Operating Systems Windows
Last update 2015-06-16 03:46:19.0
Supported by
Community Source powershell-execute-a-script-remotely

Broadcom does not support, maintain or warrant Solutions, Templates, Actions and any other content published on the Community and is subject to Broadcom Community Terms and Conditions.