1 Reply Latest reply on Jul 15, 2020 3:30 PM by Jeffrey Jordan

    passing parms from controlm to powershell script

    Jeffrey Jordan
      Share This:

      I'm having an issue passing needed parms from controlm command line to powershell script to then use them. Something off in the syntax of the variable in powershell script. Basically here's what I'm doing -

      controlm job command line

      powershell.exe -command C:\ControlM\Scripts\oracle_ftp.ps1 %%PARM1 %%PARM2 %%PARM3 %%PARM4 %%PARM9

      powershell script to define the parms into a variable used in the ps script at various parts-

      #Set sftp variables

      $sourcehost = %1

      $sourcepath = %2

      $sourceuser = %3

      $filea = %4

      $type = %9

       

      I've executed ps script manually by hard coding the parms into what would be passed & it works, so the powershell script is fine, it's just the passing of the parms to the ps script isn't working

       

      PARM1 needs to be what in my powershell script? I've tried %1 as well as $1 & it kicked error on both

       

      here's sysout w/ %1 type variable -

      powershell.exe -command C:\ControlM\Scripts\oracle_ftp.ps1 "server.com" "/opt/ctmagent/" "ctmagent" "test1.dat" "ASCII"
      %1 : The term '%1' is not recognized as the name of a cmdlet, function, script
      file, or operable program. Check the spelling of the name, or if a path was
      included, verify that the path is correct and try again.
      At C:\ControlM\Scripts\oracle_ftp.ps1:4 char:15
      + $sourcehost = %1
      +               ~~
          + CategoryInfo          : ObjectNotFound: (%1:String) [], CommandNotFoundE
         xception
          + FullyQualifiedErrorId : CommandNotFoundException

      %2 : The term '%2' is not recognized as the name of a cmdlet, function, script
      file, or operable program. Check the spelling of the name, or if a path was
      included, verify that the path is correct and try again.
      At C:\ControlM\Scripts\oracle_ftp.ps1:5 char:15
      + $sourcepath = %2
      +               ~~
          + CategoryInfo          : ObjectNotFound: (%2:String) [], CommandNotFoundE
         xception
          + FullyQualifiedErrorId : CommandNotFoundException

      %3 : The term '%3' is not recognized as the name of a cmdlet, function, script
      file, or operable program. Check the spelling of the name, or if a path was
      included, verify that the path is correct and try again.
      At C:\ControlM\Scripts\oracle_ftp.ps1:6 char:15
      + $sourceuser = %3
      +               ~~
          + CategoryInfo          : ObjectNotFound: (%3:String) [], CommandNotFoundE
         xception
          + FullyQualifiedErrorId : CommandNotFoundException

      %4 : The term '%4' is not recognized as the name of a cmdlet, function, script
      file, or operable program. Check the spelling of the name, or if a path was
      included, verify that the path is correct and try again.
      At C:\ControlM\Scripts\oracle_ftp.ps1:7 char:10
      + $filea = %4
      +          ~~
          + CategoryInfo          : ObjectNotFound: (%4:String) [], CommandNotFoundE
         xception
          + FullyQualifiedErrorId : CommandNotFoundException

      %9 : The term '%9' is not recognized as the name of a cmdlet, function, script
      file, or operable program. Check the spelling of the name, or if a path was
      included, verify that the path is correct and try again.
      At C:\ControlM\Scripts\oracle_ftp.ps1:8 char:9
      + $type = %9
      +         ~~
          + CategoryInfo          : ObjectNotFound: (%9:String) [], CommandNotFoundE
         xception
          + FullyQualifiedErrorId : CommandNotFoundException

      Error: Exception calling "Open" with "1" argument(s): "SessionOptions.HostName is not set."

           Job Object statistics
           ====================
      Total User CPU Time: 0.578 second 

      Total Kernel CPU Time: 0.500 second 

      This Period Total User CPU Time: 0.578 second 

      This Period Total Kernel CPU Time: 0.500 second 

      Total Page Fault Count: 30951

      Total Processes: 4

      Active Processes: 0

      Total Terminated Processes: 0

      Total peak job memory used: 90.817 mega bytes 

       

      here's sysout w/ using $1 for variable -

       

      powershell.exe -command C:\ControlM\Scripts\oracle_ftp.ps1 "server.com" "/opt/ctmagent/" "ctmagent" "test1.dat" "ASCII"
      Error: Exception calling "Open" with "1" argument(s): "SessionOptions.HostName is not set."

           Job Object statistics
           ====================
      Total User CPU Time: 0.391 second 

      Total Kernel CPU Time: 0.188 second 

      This Period Total User CPU Time: 0.391 second 

      This Period Total Kernel CPU Time: 0.188 second 

      Total Page Fault Count: 27326

      Total Processes: 4

      Active Processes: 0

      Total Terminated Processes: 0

      Total peak job memory used: 76.214 mega bytes