AIM: How to retrieve password using AIM CP and Windows Batch

AIM: How to retrieve password using AIM CP and Windows Batch

89
Created On 11/10/26 10:56 AM - Last Modified 11/10/26 12:57 PM


Objective


How can I retrieve a password from the CLIPasswordSDK and use it in a batch file?
 


Environment


v7.2;v7.5;v7.6;v8.0;v8.0 Beta;8.1;v8.2;v8.5;v8.6;v9.0;v9.1;v9.2;9.3;9.5;9.6;9.7;9.8;9.9;9.9.5;10.0;v9.97 Privileged Access Manager (PAM, self-hosted) Credential Provider

Procedure


Please refer to the below example script. You can set the environment variables either in the script or programmatically.
 
@echo off
 
REM Declare and set variables
set AIM_AppID=YourApp
set AIM_Safe=Your-Safe
 
REM Make sure the Object Name is the "Name" value of the account stored in EPV
set AIM_Object=Operating System-WinDomain-server.example.com-AccountName
 
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
 
for /f %%A in ('%pwdcmd%') do set AIM_PW=%%A
 
if [%AIM_PW%] ==[] GOTO NOPWD
REM Place your code here for a successful password retrieval
echo "PWD is %AIM_PW%"
GOTO END
 
:NOPWD
REM Place your code here for error handling when password retrieval fails
Echo "Admin password was not fetched"
Exit /B 3
 
:End


Additional Information


Details

Q:

How can I retrieve a password from the CLIPasswordSDK and use it in a batch file?

A:

Please refer to the below example script. You can set the environment variables either in the script or programmatically.

@echo off

REM Declare and set variables
set AIM_AppID=YourApp
set AIM_Safe=Your-Safe

REM Make sure the Object Name is the "Name" value of the account stored in EPV
set AIM_Object=Operating System-WinDomain-server.example.com-AccountName

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

for /f %%A in ('%pwdcmd%') do set AIM_PW=%%A

if [%AIM_PW%] ==[] GOTO NOPWD
REM Place your code here for a successful password retrieval
echo "PWD is %AIM_PW%"
GOTO END

:NOPWD
REM Place your code here for error handling when password retrieval fails
Echo "Admin password was not fetched"
Exit /B 3

:End



Actions
  • Print
  • Copy Link

    https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA1hj0000001SALCA2&lang=en_US&refURL=http%3A%2F%2Fknowledgebase.paloaltonetworks.com%2FKCSArticleDetail