cyberark / epv-api-scripts

These API scripts enable CyberArk users to automate privileged account management task like account creation, user management, and more.
https://www.cyberark.com/best
Apache License 2.0
205 stars 176 forks source link

Accounts_Onboard_Utility fails #409

Open PinkyAndDaBrain opened 1 month ago

PinkyAndDaBrain commented 1 month ago

Summary

We upgraded to 14.2. Our account onboarding script stopped working. We tried switching to the current script instead of the older version we were using from 2021, but the script still fails.

Reproducible

Version/Tag number

v2.5.0

Environment setup

Additional Information

When running the script, it fails when evaluating $_safeOwners due to the null value of $_safeMembers.members. It seems like the API is returning the data in a different format than expected to the powershell script.

This is the same command we have been using successfully for years:

Accounts_Onboard_Utility.ps1 -PVWAURL "https://PVWAFQDN/PasswordVault" -CsvPath .\onboard_accounts_test.csv -Create -TemplateSafe "Safe_ca_Template"

$_safeOwners = $_safeMembers.members | Where-Object { $_.UserName -NotIn $_defaultUsers } | Select-Object -Property @{Name = 'MemberName'; Expression = { $_.UserName } }, Permissions

There is no "members" property in $_safeMembers object.

image (6)

$_SafeMembers= {
@{safeUrlId=Safe_ca_Template; safeName=Safe_ca_Template; safeNumber=116; memberId=##; memberName=PasswordManager; memberType=User; membershipExpirationDate=; isExpiredMembershipEnable=False; isPredefinedUser=False; isReadOnly=False; permissions= },
@{safeUrlId=Safe_ca_Template; safeName=Safe_ca_Template; safeNumber=116; memberId=###; memberName=svc_ecscyb_safemgmt; memberType=User; membershipExpirationDate=; isExpiredMembershipEnable=False; isPredefinedUser=False; isReadOnly=False; permissions= },
@{safeUrlId=Safe_ca_Template; safeName=Safe_ca_Template; safeNumber=116; memberId=##; memberName=svc_Servicename; memberType=User; membershipExpirationDate=; isExpiredMembershipEnable=False; isPredefinedUser=False; isReadOnly=False; permissions=}}

SCRIPT OUTPUT

======================================= Welcome to Accounts Onboard Utility

Starting script (v2.5.0) Current version (2.5.0) is the latest!

Getting PVWA Credentials to start Onboarding Accounts Checking Template Safe... Safe Safe_ca_Template exists You cannot call a method on a null-valued expression. At C:\temp\Accounts_Onboard_Utility.ps1:1484 char:7

Reading CSV from :C:\temp\onboard_accounts_test.csv

Starting to Onboard 2 accounts Safe safe_ca_BRTest12 exists CSV Line: 2 SafeName: "" Username: "BRTest12" Address: "DOMAIN" Object: "" Error Message: {"Details":[{"ErrorCode":"PASWS031E","ErrorMessage":"Safe [safe_ca_BRTest12] was not found","ParameterName":"safeName"}],"ErrorCode":"PASWS167E","ErrorMessage":"There are so me invalid parameters"} Exception Message: The remote server returned an error: (400) Bad Request. Status Code: 400 Status Description: Bad Request Index operation failed; the array index evaluated to null. At C:\temp\Accounts_Onboard_Utility.ps1:939 char:6

Safe safe_ca_BRTest22 exists CSV Line: 3 SafeName: "" Username: "BRTest22" Address: "Domain" Object: "" Error Message: {"Details":[{"ErrorCode":"PASWS031E","ErrorMessage":"Safe [safe_ca_BRTest22] was not found","ParameterName":"safeName"}],"ErrorCode":"PASWS167E","ErrorMessage":"There are so me invalid parameters"} Exception Message: The remote server returned an error: (400) Bad Request. Status Code: 400 Status Description: Bad Request Index operation failed; the array index evaluated to null. At C:\temp\Accounts_Onboard_Utility.ps1:939 char:6

Logoff Session...

Vaulted 0 out of 2 accounts successfully.

LogoffUrl

PinkyAndDaBrain commented 1 month ago

Updated with new output