Automic Workload Automation

  • 1.  &UC_JOBMD -- decrypted password as parameter to powershell

    Posted Oct 17, 2014 04:32 PM
    Hello,

    I need to execute a powershell script by passing a password that was extracted from a login object.But each time it failed recognize the encrypted password.When I hardcode the password it works fine.
    &UC_JOBMD  is equivalent to "C:\Automic\Agents\Windows\bin\UCXJWX6M.EXE "
    So &UC_JOBMD is not empty.

    Code :
    ! extracting password
    :SET &PW# = GET_LOGIN(TEST_LOGIN,&SERVER#,"_WINDOWS",PASSWORD)
    :PRINT This is pass &PW#  --- encrypted password

      &UC_JOBMD CMD="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File D:\pecom\appl\uc4\pshell\ps_call_remote_program.ps1 -server_user "&LOG_IN#" -server_password "%SecurePassword%" -server_name "&SERVER#" -script_name %fp_remote_script_name% -script_param1 %remote_script_parm1% -script_param2 %remote_script_parm2%"


    I also tried below option posted in this forum [it didn't work]:

    This is how I get the unencrypted password into a powershell variable;

    :JCL_SUBSTITUTE "$", "&"  
    $ &UC_JOBMD CMD='echo &PASS#'
    :JCL_SUBSTITUTE

     

    $SecurePassword = (&UC_JOBMD CMD="echo &PASS#")

    Please guide on where am I going wrong.

    Thank You,

    Pratima




  • 2.  &UC_JOBMD -- decrypted password as parameter to powershell

    Posted Oct 17, 2014 05:20 PM
      |   view attached
    I had to figure out how to do this just a few months ago.  I collected a lot of knowledge from multiple people in these forums and on other blog sites to get it working.

    I've attached the solution we are now using.  It is a UC4 include object that we run at the top of all of our PowerShell process scripts.  You pass it the name of your target server, and it builds a PowerShell $Cred object for that server.  It pulls userid/password out of LOGIN.POWERSHELL.  The logic that populates UC_JOBMD is custom built for my datacenter to support the fact that we have 2 servers still running 32 bit.  It requires some other site-specific mods as well.

    Pete

    Attachment(s)

    xml
    uc4_export.xml   5 KB 1 version


  • 3.  &UC_JOBMD -- decrypted password as parameter to powershell

    Posted Oct 19, 2014 06:55 PM
    Here's example from a post made about passing a Password from a PromptSet to a SQLPlus job.


  • 4.  &UC_JOBMD -- decrypted password as parameter to powershell

    Posted Oct 20, 2014 03:41 PM
    Thank You Pete and Jennifer. Iam trying the options you provided.
    Also I wanted to check why are we extracting part of the password? Its encrypted.
    :set &ServerPassword# = substr(&ServerPassword#,3)
    :set &ServerPassword# = str_cat("--",&ServerPassword#)  

    For the below code will 
    $SecurePassword  contain unencrypted password.
    Echo displays "N" in my case.

    calling this batch code below with in process tab of windows job::
    :SET &UC_JOBMD = "C:\Automic\Agents\Windows\bin\UCXJWX6M.EXE" 
    :SET &PW# = GET_LOGIN(TEST_LOGIN,&SERVER#,"_WINDOWS",PASSWORD)
    :PRINT This is pass &PW#
    :SET &SecurePassword# = (&UC_JOBMD CMD="echo &PW#")
    :PRINT This is passcode &SecurePassword#


    &UC_JOBMD CMD="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File D:\pecom\appl\uc4\pshell\ps_call_remote_program.ps1 -server_user "&LOG_IN#" -server_password "&PW#" -server_name "&SERVER#" -script_name %fp_remote_script_name% -script_param1 %remote_script_parm1% -script_param2 %remote_script_parm2%"

    Results:
    2014-10-20 11:13:43 - U0020408 This is pass --1036178E0EBFDA14DC
    2014-10-20 11:13:43 - U0020408 This is passcode N


    Currently I can't test further because the server account got locked due to multiple failed attempts.
    In the meanwhile I thought of playing around with echo of the password.






  • 5.  &UC_JOBMD -- decrypted password as parameter to powershell

    Posted Oct 20, 2014 05:13 PM
    Can you clarify about the extraction of part of the password?


    The encryption will prevent the password from showing in clear text in any of the logs. 

    The &UC_JOBMD decrypts any password within the quotes. 


  • 6.  &UC_JOBMD -- decrypted password as parameter to powershell

    Posted Oct 20, 2014 05:22 PM
    We are on V9-SP5 which has a defect that causes the first two bytes of the encrypted password to be returned as undesirable characters.  The two statements you posted here are the workaround for that V9-SP5 defect.


  • 7.  &UC_JOBMD -- decrypted password as parameter to powershell

    Posted Oct 20, 2014 06:47 PM
    Yes UC_JOBMD can be used to expose passwords.  This is one of the reasons you must restrict access to your production systems.


  • 8.  &UC_JOBMD -- decrypted password as parameter to powershell

    Posted Oct 21, 2014 01:58 PM
    Hello, first time using this and I LOVE IT. Already found a solution for this and thank you. BTW, i work with Pratima. Thank you Jennifer, and Pete.


  • 9.  &UC_JOBMD -- decrypted password as parameter to powershell

    Posted Oct 22, 2014 03:33 PM
    Thank you Pete and Jennifer for your suggestions.