product icon

How to Run an Automated PowerShell Script

Create automated PowerShell scripts that you can run on multiple computers without user interaction.

Important: To create or run an automated PowerShell script the user must be authenticated with Two-Factor Authentication (2FA). This added security step serves the security of the session, as no host credentials are needed.

Authentication is required only once during the session. If 2FA is set to on demand, the user has to authenticate themselves when they click Create new job or Rerun, otherwise 2FA is done on login.

  1. On the Manage page under Remote Execution click Create new job.

    Result: The Create job page is displayed.

  2. Add the PowerShell execution step to the list on the left.
  3. Paste your PowerShell script to the field. You can also select files to upload that the target computers can download.
    Note: You can reference the file(s) from the script. You can upload up to three files per job with a maximum size of 1GB each. Any file can be used.
  4. From the list of Computers define the computers or a group of computers that will receive the script.
  5. Enter a friendly name that you can easily remember later on.
  6. Click Run.
    Note: A preset timeout pertains to both the job and the task.

    The timeout of the job is 24 hours. Practically this means that computers can download the script and report back the result for one day.

    Task timeout is set to two hours, that is the target computer waits two hours for the script to start running.

Results:
Note:

When you reference a file from the script, you only have to enter its name. The path of the file is stored in the central_FilesPath environment variable. Once the task ends, the file is deleted from the target computer, unless it is copied somewhere else with the script.

Example:

You upload 'a.txt' file for the job and you would like to copy it into a folder (also known as file distribution). Your script should look something like this:
Copy-Item a.txt C:\Destination
Article last updated: 21 November, 2022