infamousjoeg
1/30/2017 - 8:15 PM

AIM CP Batch Example

AIM Example

@echo off

REM Declare and set variables
set Admin_ID=Svc_CyberArkREST
set AIM_AppID=AIM-CP-Test
set AIM_Safe=T-APP-CYBR-RESTAPI
REM Make sure the Object Name is the "Name" value of the account stored in EPV
set AIM_Object=Operating System-WinDomain-joe-garcia.local-Svc_CyberArkREST

REM Set AIM CP CLI command to run
set pwdcmd=C:\Progra~2\CyberArk\ApplicationPasswordSdk\CLIPasswordSDK.exe password /p "AppDescs.AppID=%AIM_AppID%" /p "query=Safe=%AIM_Safe%;Folder=Root;object=%AIM_Object%" /o Password

REM For every value returned from pwdcmd set the only value to Admin_PW
for /f %%A in ('%pwdcmd%') do set Admin_PW=%%A

if [%Admin_PW%] ==[] GOTO NOPWD

echo "PWD is %Admin_PW%"

GOTO END

:NOPWD
Echo "Admin password was not fetched"
Exit /B 3

:End