Linked Reconcile account via scripting

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

Linked Reconcile account via scripting

L3 Networker

Hi everyone,

 

I am having multiple un-link accounts in my setup and i would like to do it but not manually.

 

I found this script from GitHub: https://github.com/cyberark/epv-api-scripts/tree/main/Linked%20Accounts

 

But not sure that it is suitable for version 14.2 i use cause i am getting this error logs:

 

.\Link-Accounts.ps1 -PVWAURL cyberark.xxxxxx.xx -CSVPath "C:\Users\\CBA\API\epv-api-scripts\Linked Accounts\Link-Accounts.csv" -AuthType cyberark -concurrentSession

=======================================

Welcome to the Account Link Utility

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

Getting PVWA Credentials to start Linking accounts

Join-ExceptionMessage : Cannot process argument transformation on parameter 'e'. Cannot convert the "System.Exception: Get-LogonHeader: ---> System.Management.Automation.RuntimeException: Unable to find type 

[Microsoft.PowerShell.Commands.HttpResponseException].

  at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)

  at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)

  at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

  at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

  at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)

  at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)

  at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)

  at System.Management.Automation.PSScriptCmdlet.DoEndProcessing()

  at System.Management.Automation.CommandProcessorBase.Complete()

  --- End of inner exception stack trace ---" value of type "System.Exception" to type "System.Management.Automation.ErrorRecord".

At C:\Users\\CBA\API\epv-api-scripts\Linked Accounts\Link-Accounts.ps1:693 char:86

+ ... -MSG "Error Logging on. Error: $(Join-ExceptionMessage $_.Exception)"

+                              ~~~~~~~~~~~~

  + CategoryInfo     : InvalidData: (:) [Join-ExceptionMessage], ParameterBindingArgumentTransformationException

  + FullyQualifiedErrorId : ParameterArgumentTransformationError,Join-ExceptionMessage

 

Importing accounts to link

Remove-Item : Cannot bind argument to parameter 'Path' because it is null.

At C:\Users\CBA\API\epv-api-scripts\Linked Accounts\Link-Accounts.ps1:706 char:13

+ Remove-Item $csvPathBad -Force -ErrorAction SilentlyContinue

+       ~~~~~~~~~~~

  + CategoryInfo     : InvalidData: (:) [Remove-Item], ParameterBindingValidationException

  + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.RemoveItemCommand

 

Found a total of 1 accounts with links

A total of 0 ExtraPass1 accounts found

A total of 0 ExtraPass2 accounts found

A total of 1 ExtraPass3 accounts found

A total of 1 account links found

Starting to add links to 1 master accounts

Searching for Master Account with username "XX.CBA.ACCESS.USER05" with address "XX-VWL5286.XXXX.NET" in safe "ACESSCARD".

System.Management.Automation.RuntimeException: Unable to find type [Microsoft.PowerShell.Commands.HttpResponseException].

  at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)

  at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)

  at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

  at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

  at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)

  at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)

  at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)

  at System.Management.Automation.PSScriptCmdlet.DoEndProcessing()

  at System.Management.Automation.CommandProcessorBase.Complete()

Error searching for Master Account with username "XX.CBA.ACCESS.USER05" with address "XX-VWL5286.XXXX.NET" in safe "ACESSCARD".

Message: No Master Account Found

concurrentSession passed, session NOT logged off

A total of 0 accounts with 1 links imported

A total of 0 ExtraPass1 links out of 0 links where created successfully.

A total of 0 ExtraPass2 links out of 0 links where created successfully.

A total of 0 ExtraPass3 links out of 1 links where created successfully.

A total of 0 individual links out of 1 links where created successfully.

 

 

But the account is clearly exists and i can access with the account that i use to run this script.

Field_Content_versions_oct20__068Vy00001MZ4WeIAL.png

1 accepted solution

Accepted Solutions

L4 Transporter

I think the error happens before the script interacts with any account in your Vault - from the output you posted, the script isn't even logging on to your PVWA server.

 

One potential problem: The script wants the PVWA URL as the actual URL, meaning something like this:

-PVWAURL "https://cyberark.company.local/PasswordVault"

I think you are specifying only the hostname part ("cyberark.company.local" or similar).

 

Another potential issue is that the credentials you provide are wrong.

 

I don't think the double-backslashes in the path are an issue, PowerShell is usually pretty smart about still recognizing the intended path.

View solution in original post

12 REPLIES 12

L7 Applicator

Hey @Quang Le​ 

It looks like it should work, but it's having trouble finding the master account name.

 

Does the account name start with a special character? Can you attempt it with a test account with a simple name to see if the same error occurs?

 

-Matt

L3 Networker

Hi @Matt Jennison​ ,

 

I don't really sure what is the master account that the script looking for? Was it the account in the picture that i posted? If so, the account just start with capital letter. Yeah, let me try with account that is more simple.

the master account would be the account you want to link the reconcile account to.

 

Let me know how things go!

 

-Matt

Hi @Matt Jennison​ ,

 

I have tried to create new account with username is "test" and try again but no luck. Still the same error message:

 

 

.\Link-Accounts.ps1 -PVWAURL cyberark.xxxxxxxx.xx -CSVPath "C:\Users\\Link-Accounts.csv" -AuthType cyberark -concurrentSession ======================================= Welcome to the Account Link Utility ------------------------------------ Getting PVWA Credentials to start Linking accounts Join-ExceptionMessage : Cannot process argument transformation on parameter 'e'. Cannot convert the "System.Exception: Get-LogonHeader: ---> System.Management.Automation.RuntimeException: Unable to find type [Microsoft.PowerShell.Commands.HttpResponseException]. at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0) at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess) at System.Management.Automation.PSScriptCmdlet.DoEndProcessing() at System.Management.Automation.CommandProcessorBase.Complete() --- End of inner exception stack trace ---" value of type "System.Exception" to type "System.Management.Automation.ErrorRecord". At C:\Users\\epv-api-scripts\Linked Accounts\Link-Accounts.ps1:693 char:86 + ... -MSG "Error Logging on. Error: $(Join-ExceptionMessage $_.Exception)" + ~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Join-ExceptionMessage], ParameterBindingArgumentTransformationException + FullyQualifiedErrorId : ParameterArgumentTransformationError,Join-ExceptionMessage   Importing accounts to link Remove-Item : Cannot bind argument to parameter 'Path' because it is null. At C:\Users\\epv-api-scripts\Linked Accounts\Link-Accounts.ps1:706 char:13 + Remove-Item $csvPathBad -Force -ErrorAction SilentlyContinue + ~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Remove-Item], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.RemoveItemCommand   Found a total of 1 accounts with links A total of 0 ExtraPass1 accounts found A total of 0 ExtraPass2 accounts found A total of 1 ExtraPass3 accounts found A total of 1 account links found Starting to add links to 1 master accounts Searching for Master Account with username "test" with address "xxxxxxxxx.net" in safe "Jira_support_xx". System.Management.Automation.RuntimeException: Unable to find type [Microsoft.PowerShell.Commands.HttpResponseException]. at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0) at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess) at System.Management.Automation.PSScriptCmdlet.DoEndProcessing() at System.Management.Automation.CommandProcessorBase.Complete() Error searching for Master Account with username "test" with address "xxxxxxxxxxx.net" in safe "Jira_support_xx". Message: No Master Account Found concurrentSession passed, session NOT logged off A total of 0 accounts with 1 links imported A total of 0 ExtraPass1 links out of 0 links where created successfully. A total of 0 ExtraPass2 links out of 0 links where created successfully. A total of 0 ExtraPass3 links out of 1 links where created successfully. A total of 0 individual links out of 1 links where created successfully.

 

Hey @Quang Le​ 

Honestly, I'm not quite sure why this wouldn't be working right now.

 

Do you have this process working on another account? If so, you can review these settings to see what may differ within this setup.

 

-Matt

L4 Transporter

Hello,

In several places in the posted logs there seems to be an extra backslash in the path for the CSV file. The process appears to be failing on the path so I would focus on fixing that first.

L4 Transporter

I think the error happens before the script interacts with any account in your Vault - from the output you posted, the script isn't even logging on to your PVWA server.

 

One potential problem: The script wants the PVWA URL as the actual URL, meaning something like this:

-PVWAURL "https://cyberark.company.local/PasswordVault"

I think you are specifying only the hostname part ("cyberark.company.local" or similar).

 

Another potential issue is that the credentials you provide are wrong.

 

I don't think the double-backslashes in the path are an issue, PowerShell is usually pretty smart about still recognizing the intended path.

Hi @Bernhard Brückler​ , i will try but in the output log it saids "Found a total of 1 accounts with links" If it isn't even logging on to my PVWA server, how can it find the account with links?

Hi, thank you but it just because i remove it myself to not expose private data.

Hi i don't understand what you mean about "have this process working on another account?"

Btw, i then write a python script to use REST API to link and it works perfectly. Just want to know why it isn't work with the tool provide by CyberAk.

Because the script gets that info from the CSV file.

Hi @Bernhard Brückler​ , you got it right. I test and it is working.

 

The URL must be something like: https://cyberark.company.local/PasswordVault

 

Not:

  • https://cyberark.company.local
  • cyberark.company.local/PasswordVault
  • cyberark.company.local

 

Even those other URL still pop-up login but it doesn't working. Always have to be https://cyberark.company.local/PasswordVault

  • 1 accepted solution
  • 116 Views
  • 12 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!