Run Power Shell Script via CPM.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

Welcome Idira to LIVEcommunity!

Our community just got stronger! Explore new identity security resources, connect with experts, and discover more ways to learn and collaborate.

Meet Idira

Run Power Shell Script via CPM.

L4 Transporter

I have service account that I will be using for Veeam Backups.  The service account has to be in the domain admin group.

 

I would like to set the password to be CPM controlled but also have the CPM change the password within the Veeam environment.

 

The password can be changed via PS script as long as the VeeamPSSnapin is loaded into the PS shell.

 

https://helpcenter.veeam.com/docs/backup/powershell/add-vbrcredentials.html?ver=95

 

Question: anyone do anything like this before.  Can the CPM be configured to run a PS1 script at the same time that it changes the password in Active Directory?

 

31 REPLIES 31

L2 Linker

thanks for reply

I'm not sure to understand how to distinguish between Logon phase and change password phase is it in the process file?

Yes. You have to end the logon phase instantly only at change phase the newpassword variable will be filled.

I'm not sure to understand ho to Distinguish logon or password change phases.

Is it set in process.ini file?

maybe exist a template file based on CyberArk.TPC.exe plugin ?

L2 Linker

i'm trying this (I have truncated ScriptNames)

StartScript=(spawn)C:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe & '.\\bin\\CHGPassword_PSv1.ps1' -User <username> -CurrentPW <pmpass> -NewPass <pmnewpass> -Targ <address>

 

Did you try to verify an account? Does that work?

L2 Linker

No i did not implement the verify feature until i'm sure the newpassword is passed in the script argument.

Wri

Could you please share how the logon phase can be skipped or ended instantly?

​Hello

In the process file the END is required to finish a step

Action, Promt, NextAction

NextAction, True, END  will exit from the step en goes to next step (verify, change)

L2 Linker

@Dave Zuver​ Did you ever get this working ? I have a similar requirement but stuck in between (we are using pmterminal.exe). I also need CPM to execute a powershell so that a REST call can be made

L2 Linker

@Dave Zuver​ Did you ever get this working ? I have a similar requirement but stuck in between (we are using pmterminal.exe). I also need CPM to execute a powershell so that a REST call can be made

We just got this working. We created a separate platform under service accounts. It uses TPC instead of PMTerminal and invokes a powershell that then makes the REST API calls to push the password to a target application. We then tied this in the usages for the Active Directory account so that every time the password is changed, CPM pushes this via the usage platform (using the powershell RestAPI).

Let me know if you need any specifics.

@Ramkumar Thirumangalam​ If possible could you share the process/prompts file ? (ofcourse after removing everything relevant to your organization)

@Ramkumar Thirumangalam​ If possible could you share the process/prompts file ? (ofcourse after removing everything relevant to your organization)

@Anand Negi​ Sorry, I just saw your message. Here you go.

Process File

==========

##########################################################################

###          Pega Process FILE

##########################################################################

 

#States names can contain only alphabet and numeric characters

[states]

 

#Initialization

Init=(script)set verifyLogon 0;

CheckResult

CheckReconcileResult

 

StartScript=(spawn)"PowerShell.exe" ".\\bin\\Pega.ps1" -action '<action>' -address '<address>' -webserviceurl '<WebServiceURL>'

 

SendLogonPass=<pmpass>

SendNewPass=<pmnewpass>

SendResetPass=<pmnewpass>

SendReconcilePass=<pmextrapass3>

 

 

#Final state

END

 

#Failure states

FailInvalidUsernameOrPassword=FAIL(Supplied credential is invalid, 2114)

FailConstraintViolated=FAIL(There is a constraint violation. Either the user is locked or another password policy constraint was broken, 2115)

FailAccessDenied=FAIL(User has insufficient access rights, 2101)

FailWrongAddress=FAIL(Cannot contact the LDAP server. Make sure that the address and port are correct, 2104)

FailNoSuchUser=FAIL(Object does not exist, 2105)

FailTimeout=FAIL(Search timed out. (Check security parameters), 2111)

 

FailReadOnly=FAIL(Server cannot perform operation. Either user is inactive, user has no permissions to change its password or server is read only, 8003)

FailObjecCreateFailure=FAIL(Failed to get LDAP object, 8010)

FailLogonUnknownReason=FAIL(Failed to logon for unknown reason, 8011)

FailChangePasswordUnknownReason=FAIL(Failed to change the password for unknown reason, 8012)

FailCommit=FAIL(Failed to commit password change, 8013)

FailResetPasswordUnknownReason=FAIL(Failed to reset the password for unknown reason, 8014)

 

FailRECInvalidUsernameOrPassword=FAIL(Reconciliation task - Supplied reconcile user credential is invalid, 8015)

FailRECNoSuchUser=FAIL(Reconciliation task - Reconcile or target object does not exist, 8016)

 

FailMissingArgs=FAIL(Not enough arguments, 8017)

FailWrongArg=FAIL(One of the arguments that sent to terminal was wrong, 8017)

FailWrongAction=FAIL(The action does not exists or not supported by this plugin, 8017)

FailInvalidAction=FAIL(The action specified is invalid for this type of plug-in, 8018)

 

FailInvalidSyntax=FAIL(Distinguished name has invalid syntax, 8030)

FailInvalidPath=FAIL(An invalid pathname was passed, 8031)

 

 

[transitions]

#CurrentState         Condition         NextState

#------------         ---------------       -------------- 

#############################################################################

#              INITIALIZATIONS

#############################################################################

Init,          TRUE,           StartScript

 

#############################################################################

#              Invoke PowerShell

#############################################################################

StartScript,        MissingArgs,         FailMissingArgs

StartScript,        WrongArg,           FailWrongArg

StartScript,        WrongAction,         FailWrongAction

 

#############################################################################

#              Logon action - Irrelevant - skip 

#############################################################################

StartScript,        LogonIrrelevant, CheckResult

 

#############################################################################

#              Change or reconcile action  

#############################################################################

StartScript,        NewPass,   SendNewPass

SendNewPass,           EndGetPass,          CheckResult

 

CheckResult,           LogonFailed,         FailInvalidUsernameOrPassword        

CheckResult,           InvalidPath,         FailInvalidPath

CheckResult,           AccessDenied,         FailAccessDenied

CheckResult,           Timeout,           FailTimeout

CheckResult,           ConstraintViolation,     FailConstraintViolated

CheckResult,           ObjectNotExist,        FailNoSuchUser

CheckResult,           InvalidSyntax,        FailInvalidSyntax

CheckResult,           ReadOnly,           FailReadOnly

CheckResult,           CannotContactServer,     FailWrongAddress

CheckResult,           WebServiceError,      FailChangePasswordUnknownReason

CheckResult,           WebServiceException,     FailChangePasswordUnknownReason

CheckResult,           GeneralChangeFail,      FailChangePasswordUnknownReason

CheckResult,           IsSuccessful,         END

CheckResult,           SuccessReturnCode,      END

 

[CPM Parameters Validation]

address, source=FILE, Mandatory=no

pmextrapass3,source=ENV, Mandatory=([string equal -nocase "<action>" "reconcilepass"]||[string equal -nocase "<action>" "prereconcilepass"])

extrapass3\userdn, source=FILE, Mandatory=![string equal -nocase "<pmextrapass3>" ""] 

 

[parameters]

PromptTimeout=50

#SendSlow=1 .001

SendHuman=.1 .3 1 .05 2

#Stty - valid values are one or more of: echo, raw, cooked, -echo, -raw, -cooked

#Stty=

 

[Debug Information]

DebugLogFullParsingInfo=no

DebugLogFullExecutionInfo=no

DebugLogDetailBuiltInActions=no

ExpectLog=no

ConsoleOutput=no

 

 

----------------------------

Prompts File

 

##########################################################################

### PEGA PROMPTS FILE

##########################################################################

 

#Conditions names can contain only alphabet and numeric characters

[conditions]

Password=PEGAPlugIn -\> Action=Logon Operation=EnterPass :

 

TRUE=(expression)true

 

# Prompts

MissingArgs=Missing arguments. Usage

LogonIrrelevant=.*Logon Operation is irrelevant and skipped.*

ReconcileUserPass=.*Action=Reconcile Operation=EnterPass Pass=ReconcileUser :.*

#ReconcileUserPass=.*PEGAPlugIn -\> Action=Reconcile Operation=EnterPass Pass=ReconcileUser :.*

EndGetPass=.*Password was successfully read.*

NewPass=.*Operation=EnterPass Pass=New :.*

#NewPass=.*PEGAPlugIn -\> Action=.* Operation=EnterPass Pass=New :.*

WrongArg=Wrong argument value.

WrongAction=Wrong action.  

 

#Fail Prompts

LogonFailed=49

InvalidPath=80005000

AccessDenied=80070005

Timeout=800705B4

ConstraintViolation=8007202F

ObjectNotExist=32

InvalidSyntax=80072032

ReadOnly=80072035

CannotContactServer=81

WebServiceError=1000

WebServiceException=1001

 

#General fail prompts

GeneralChangeFail=.*An error has occurred.* 

 

 

IsSuccessful=.*Action ended successfully.*

SuccessReturnCode=0

 

  • 4836 Views
  • 31 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!