Harvest

 View Only
Expand all | Collapse all

How can I execute an powershell script with parameters via hexecp?

  • 1.  How can I execute an powershell script with parameters via hexecp?

    Posted Jul 16, 2015 12:34 PM

    I want to execute a powershell script using parameters in a remote machine.

     

    The -parametername is not working.

     

     

    Regards,

     

    Tania Moreno

    eSoft

    Venezuela



  • 2.  Re: How can I execute an powershell script with parameters via hexecp?

    Posted Jul 16, 2015 12:59 PM

    Hello, Tania.

     

    Can you show us what command are you executing?

    It seems you are mixing some parameter names.

    hexecp should be have parameters {-prg program} ... [-args arguments...] ..., as shown on the Command Line Reference Guide.

     

    Best regards,

    Ricardo Bernardino



  • 3.  Re: How can I execute an powershell script with parameters via hexecp?

    Posted Jul 16, 2015 02:43 PM

    Hello Ricardo,

     

    I want to run the script that runs in cmd window...

     

    powershell.exe BajaServicio.ps1 -servicio "Tomcat"

     

    but when I tried to run remotely via hexecp the parameter -servicio, gives me error with Harvest command interpreter.

     

    Do I explain now?

     

    Regards,

     

     

    Tania Moreno



  • 4.  Re: How can I execute an powershell script with parameters via hexecp?

    Posted Jul 17, 2015 10:38 AM

    Hello, Tania.

     

    I now understand what you are trying to do, but in order to help you find what is wrong I will need to see exactly what you are executing: hexecp ...

    It seems that some of the hexecp parameters could be wrong.

     

    Best regards,

    Ricardo Bernardino



  • 5.  Re: How can I execute an powershell script with parameters via hexecp?

    Posted Jul 20, 2015 09:30 AM

    Hello Ricardo,

     

    Thanks for your time.

     

    The command that don't work is as follows...

     

    hexecp -prg powershell.exe -m 10.1.1.53 -rport 10001 -syn -args "F:\Program Files\CA\SCM\CASCM_BajaServicio.ps1" "-servicio" "Apache Tomcat 6" -ma -er remoteuser.dfo -oa log.log -wts -v

     

    Best regards!

     

    Tania



  • 6.  Re: How can I execute an powershell script with parameters via hexecp?
    Best Answer

    Posted Jul 20, 2015 10:55 AM

    Hello.

     

    It seems that the command line parser from Harvest is processing -servicio (because of the dash "-") as an Harvest option, so you should encapsulate it.

    I think you should try "\-servicio" or "\"-servicio\"", but I am not sure which one will work better for you.

     

    Best regards,

    Ricardo Bernardino



  • 7.  Re: How can I execute an powershell script with parameters via hexecp?

    Posted Jul 20, 2015 04:31 PM

    Hello Ricardo,

     

    That was my solution. It works!

     

    Best regards!  and a hug!

     

    Tania



  • 8.  Re: How can I execute an powershell script with parameters via hexecp?

    Posted Nov 15, 2018 02:34 PM

    Hello, Where I have to put the remoteuser.dfo ?

     

    In the remote server or in harvest server? and in what path? 

     

    Can anybody help me please?



  • 9.  Re: How can I execute an powershell script with parameters via hexecp?

    Broadcom Employee
    Posted Nov 15, 2018 05:15 PM

    The remoteuser.dfo file should be installed on the same computer where the hexecp executeable will be run.  If you have set this up as  UDP, hexecp will execute on the broker machine.  In the above example:

     

    hexecp -prg powershell.exe -m 10.1.1.53 -rport 10001 -syn -args "F:\Program Files\CA\SCM\CASCM_BajaServicio.ps1" "-servicio" "Apache Tomcat 6" -ma -er remoteuser.dfo -oa log.log -wts -v

     

    We can say that the hexecp program will login to the SCM agent on computer 10.1.1.53, over port 10001, using the login credentials found in remoteuser.dfo, and will execute the powershell.exe command there.

     

    Let me know if this helps. 



  • 10.  Re: How can I execute an powershell script with parameters via hexecp?

    Posted Nov 15, 2018 05:25 PM

    Ok Melinda but in what path or route I have to put this file ? How or where I have to set the path ?

     

    Something like this:

     

    hexecp -prg perl -ma -args "C:\path\script.pl" [project] [package] [user] -syn -m name_server -er “C:\path\credential.dfo” -rport 1576

     

    But it doesn't work... 

     

     

    Thanks



  • 11.  Re: How can I execute an powershell script with parameters via hexecp?

    Broadcom Employee
    Posted Nov 15, 2018 05:57 PM

    I will check to find the answer and let you know.  I would expect that including the full path to the dfo would be sufficient, I could be wrong.  Will let yo know what I find out.  Thanks



  • 12.  Re: How can I execute an powershell script with parameters via hexecp?

    Broadcom Employee
    Posted Nov 16, 2018 02:20 PM

    I tested and found you must include the path to the DFO file in your hexecp command.  Here is an example:

     

    My dfo file is found here:

    And my hexecp command looks like this:

     

    Let me know if this makes sense.



  • 13.  Re: How can I execute an powershell script with parameters via hexecp?

    Posted Nov 16, 2018 03:13 PM

    Hi Melinda, thanks a lot.

     

    Let me understand..

     

    Your dfo file is in the remote server?

     

    The dfo file containts the user-pass of an user domain of windows or containts the user-pass of an user Harvest?

     

    Thanks



  • 14.  Re: How can I execute an powershell script with parameters via hexecp?

    Broadcom Employee
    Posted Nov 16, 2018 03:21 PM

    The dfo file will be on the broker machine because it is the hexecp executable that needs to use it.  It should contain the login credentials that would allow hexecp to login to the remote agent machine so that it can execute the command or script specified with the "-prg" option.

     

    Let me know if this makes sense



  • 15.  Re: How can I execute an powershell script with parameters via hexecp?

    Posted Nov 23, 2018 12:25 PM

    Hi Melinda, I have tried that, but the message was the same...

    ERROR: Unable to open file:

    I did this:

    I put the dfo file into my harvest server.

    My UDP look like this:

    hexecp -prg perl -ma -args "C:\Harvest-FF\script.pl" [project] [package] [user] -syn -m remote_server_name -er "/herramientas/CA/credenciales/credencial.dfo" -rport 1576

     

    So, I have a question... What is the User that read the dfo file?  Is my loggin user?  or is another user?

    This for I give access to this user.

     

    *** My harvest server has SO Unix, so my path is "/herramientas/CA/credenciales/credencial.dfo" but I am not sure if hexecp can read this path from this way.

     

    Thanks