• Documentation
  • Workato Blog
  • Product Blog
  • Return to Workato
  • Login
  • Automation Institute
  • Documentation
  • Community Forums
New Topic
Discussions Recipe Building Recipe Error Troubleshooting
A

ACL Services Ltd.

started a topic over 4 years ago

On-Prem command line script

Hi,


I have an on-prem agent installed and am trying to execute a powershell ps1 script. I have tested it locally without Workato by using >PowerShell.exe -file "C:\Documents\test.ps1" and it works.


command_line_scripts:

  test_profile:

    concurrency_limit: 3

    scripts:

     test_script:

       name: test_script

       command:

         - 'C:\Windows\System32\WindowsPowershell\v1.0\powershell.exe -file C:\Documents\test.ps1'


But I am getting a weird error:
Cannot run program "C:\Windows\System32\WindowsPowershell\v1.0\powershell.exe -file C:\Documents\test.ps1": CreateProcess error=2, The system cannot find the file specified

I have tried double black slashes, forward slashes, back slashes....and all get errors. Anyone has used workato to execute a powershell script?


2 people have this question

Marlon Muela

said almost 4 years ago

Hi ACL Services Team,


Apologies for the lates response on this topic.


You may check this link on how to create a command line script for your On-Prem agent: https://docs.workato.com/on-prem/profile.html#command-line-scripts-profile

Also, regarding this issue, may we know if you are using Workato as a normal user? If there are different admin rights, then the script might fail.


R

Robert Sim

said almost 2 years ago

For future reference on how to run Powershell script through command line scripts profile, since this comes up as one of the few results in Google for Powershell usage in Workato.


1. Set execution policy to RemoteSigned, with local machine scope in an administrative Powershell:  

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine

 

2. yaml file setting (that worked for me):

   

command_line_scripts:
  Developer_1:
    concurrency_limit: 3
    timeout: 30
    scripts:
      server_stats:
        name: Get Server Stats
        command:
          - 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'
          - '<path to file directory>\developerlab2.ps1 -input_stats {{type}}'
        parameters:
          - { name: type }

 

3. Start of ps file

 

Param(
    [Parameter(Mandatory=$True,Position=1)]
    [string]$input_stats,
    [switch]$force = $false
    ) 

   

Login to post a comment

Still can't find your solution?

Send us a ticket, we will try our best to assist you with your problem

Documentation
Developer's Library
Tutorials
eBooks
Product Hour
Product Blog
Workato Blog
Product updates
Customer Stories
© Workato 2022   Privacy   Terms   +1 (844) 469-6752
  • Documentation
  • Workato Blog
  • Product Blog
  • Solutions
  • Forums
  • Tickets
  • Log in
  • Return to Workato
Topic views count