ESP Workload Automation

 View Only
  • 1.  PowerShell for ESPlmi

    Posted Jun 18, 2020 02:16 PM
    What is the exact syntax needed in a PowerShell script to call ESPlmi?

    I have reviewed existing discussions. Excuse me if this is already documented in this forum.

    I want to change from having my existing ESP job which calls a .bat to have it call a PowerShell script instead. My ESP job is triggering the powershell script, but then it errors as shown. In this example I am just asking ESPlmi to grab some event details.



    I have tried various quoting scenarios, comma separators, parens, but couldn't the right statement.


    the basics of the script is -

    Set-Location e:\'Program Files'\CA\WA_Agent
    ESPlmi.exe -s<server>:<port> -u<user> -p<password> -c"l level(espm2ht.dist_WNZC*280) all"


    error - 

    ESPlmi.exe : The term 'ESPlmi.exe' is not recognized as the name of a cmdlet,
    function, script file, or operable program.


    ^^^^^^^^^^^^^^^^^^^^^^^^^^

    ESPlmi 2.1.0004

    Syntax: ESPlmi -shost:port -uuserid -ppassword -ccmd -h

    When specifying an option that takes an argument, do not enter a
    space between the option and the argument. For example:
    ESPlmi -slpara:1234

    Where: -s Specifies the hostname:address and port of the Workstation
    Server. eg: hosta:3200
    -u Specifies the userid to use to log onto the Workstation
    Server.
    -p Specifies the password to use to log onto the Workstation
    Server.
    -c Specifies the command(s) to issue once logged on. The command
    can be a list of commands separated by a semi-colon. The
    command can also be a file containing commands, indicated by
    prefixing the filename (command) with an @ sign.
    eg: "-cLAP APPL.0 ALL"
    eg: "-cLSYS;LDSN"
    eg: "-c@C:\commands.txt"
    -h Displays this message. If specified, other options are
    ignored.

    ^^^^^^^^^^^^^^^^^^^^^^^^^^

    I have read that it is not best practice to have PowerShell use cmd /c
    I tried the & call operator, but did not get it to work.

    The Call Operator &
    The call operator, also known as the invocation operator
    https://social.technet.microsoft.com/wiki/contents/articles/7703.powershell-running-executables.aspx?wa=wsignin1.0


    ------------------------------
    Cigna
    ------------------------------


  • 2.  RE: PowerShell for ESPlmi

    Posted Jun 18, 2020 03:34 PM

    Windows PowerShell does not load commands from the current location by default.

    Add ./ before ESPlmi ​(  .\ESPlmi ) or enter command with the full path (e:\'Program Files'\CA\WA_Agent\ESPlmi.exe) and skip the Set-Location.



    ------------------------------
    Senior Systems Analyst
    UPS
    ------------------------------



  • 3.  RE: PowerShell for ESPlmi

    Posted Jun 19, 2020 10:02 AM
    Thank you for your help Rick. I was not able to get that to work for me, as PowerShell thinks ESPlmi means something to PowerShell (a function or cmdlet), rather than an executable on the server.

    I was able to get PowerShell to run the ESPlmi statement using cmd and quoting as noted below.
    I'll keep working on not having to use cmd, if that is possible, in favor of the Call Operator &.
    Also work on using variable rather than one long statement.

    # set directory on server where ESPlmi.exe resides
    Set-Location e:\'Program Files'\CA\WA_Agent
    # The /c tells CMD that it should terminate after the command has completed.
    cmd /c 'ESPlmi -<server> -u<user> -p<password> -c"l level(espm2ht.dist_W*******) all"'


    ------------------------------
    Cigna
    ------------------------------



  • 4.  RE: PowerShell for ESPlmi

    Posted Jun 19, 2020 10:23 AM
    Edited by Loren Watts Jun 19, 2020 10:27 AM
    I got ESPlmi to run in PowerShell using the Call Operator &, rather than invoking cmd.
    I set each component needed by ESPlmi to a variable, and then one line to call them, as shown.
    My perception is this runs faster than cmd and the statement in single quotes.
    And as Rick stated, the Set-Location is not needed.

    $CMD = '\Program Files\CA\WA_Agent\ESPlmi.exe'
    $server = '-s<server>:<port>'
    $user = '-u<user>'
    $password = '-p<password>'
    $lmicommand = '-c"l level(espm2ht.dist_W*******) all"'

    & $CMD $server $user $password $lmicommand




    ------------------------------
    Cigna
    ------------------------------



  • 5.  RE: PowerShell for ESPlmi

    Posted Jun 19, 2020 12:24 PM
    I verified the solution you posted also works in my environment.

    Thanks​

    ------------------------------
    Senior Systems Analyst
    UPS
    ------------------------------



  • 6.  RE: PowerShell for ESPlmi

    Posted Jun 22, 2020 03:24 PM
    I appreciate knowing that Rick.

    ------------------------------
    Cigna
    ------------------------------



  • 7.  RE: PowerShell for ESPlmi

    Broadcom Employee
    Posted Jun 19, 2020 10:09 AM
    Hi Loren, 
    I have not had time to test this..... I use the syntax below to issue a command.  This command is a little different but it is similar.... 

    Start-Process -NoNewWindow -FilePath "C:\Program Files\CA\WA Agent\ESPmgr.exe" -ArgumentList "DATA1/$APPLGEN/MAIN ACTION SET MYVAR(abcde)"


    If I get a minute today I will try it out with ESPlmi...


    Don