Skip to content

Instantly share code, notes, and snippets.

@infamousjoeg
Last active January 27, 2022 17:11
Show Gist options
  • Save infamousjoeg/bac4fd9f1d1d225df346ea3b8b024453 to your computer and use it in GitHub Desktop.
Save infamousjoeg/bac4fd9f1d1d225df346ea3b8b024453 to your computer and use it in GitHub Desktop.
Explanation of using AIM via Batch
Your batch script is currently:
===========================
set scmd="C:\Program Files (x86)\CyberArk\ApplicationPasswordSdk\CLIPasswordSDK.exe" password /p AppDescs.AppID=APP_AIM-TEST /p query=Safe=LNC-CMOD_DF_T;Folder=Root;Object=ARSTLOD /o Password
for /f %%A in ('"%scmd%"') do @echo pass is: %%A
arsload -fnv -u ARSTLOD -p %scmd -h ondemand-test.lnc.lfg.com,1444 -g %1 -a %2 %3
====================================
It should be:
====================================
set scmd="C:\Program Files (x86)\CyberArk\ApplicationPasswordSdk\CLIPasswordSDK.exe" password /p AppDescs.AppID=APP_AIM-TEST /p query=Safe=LNC-CMOD_DF_T;Folder=Root;Object=ARSTLOD /o Password
for /f %%A in ('"%scmd%"') do arsload -fnv -u ARSTLOD -p %%A -h ondemand-test.lnc.lfg.com,1444 -g %1 -a %2 %3
==============================
%scmd% is basically the function within this batch script. It's not the variable that's storing the password, even though it would appear that way at first glance. We're actually setting a string of code into the %scmd% variable to be run later when called upon.
Later comes when we want to get the Password and place it in the %%A object. In your current script, you just echo this out as "Pass is: password123" and that's the end of the script... until it sees your arsload and continues on doing that with an invalid and null %scmd variable.
In mine, instead of echoing the password, we're passing it off to your arsload method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment