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
201 stars 176 forks source link

Need to have more more information to be able identify which account/line has issue #179

Closed bab29 closed 3 years ago

bab29 commented 3 years ago

https://github.com/cyberark/epv-api-scripts/blob/cbb1b7e34a1581bac737270e981c829c94991a38/Account%20Onboard%20Utility/Accounts_Onboard_Utility.ps1#L253-L258

When a error gets thrown on these lines no information about which line is causing the error is getting returned.

AssafMiron commented 3 years ago

@bab29 Thanks for the info Can you get more context into this? The Throw message here is providing the missing field name, what other information is required? Can you give an example on when an error get thrown on these lines that does not provide enough information?

on the usage of the New-AccountObject, the catch phrase will parse all exceptions and write in the log file:

https://github.com/cyberark/epv-api-scripts/blob/cbb1b7e34a1581bac737270e981c829c94991a38/Account%20Onboard%20Utility/Accounts_Onboard_Utility.ps1#L1638

Thanks, Assaf

bab29 commented 3 years ago

@AssafMiron Here is part of the log. It shows what is missing but does not say what account is getting skipped.

[2021-04-13 02:40:36] [INFO] [236/5862] Added successfully. [2021-04-13 02:40:36] [INFO] Skipping onboarding account into the Password Vault. Error: Source:; Message: New-AccountObject: There was an error creating a new account object. ->Source:; Message: Missing mandatory field: Address [2021-04-13 02:40:36] [INFO] Skipping onboarding account into the Password Vault. Error: Source:; Message: New-AccountObject: There was an error creating a new account object. ->Source:; Message: Missing mandatory field: Address [2021-04-13 02:40:36] [INFO] Skipping onboarding account into the Password Vault. Error: Source:; Message: New-AccountObject: There was an error creating a new account object. ->Source:; Message: Missing mandatory field: Address

It appears the 1638 need to be updated to what I have below or something similar.

Write-LogMessage -Type Info -MSG "Skipping onboarding account _$gLogAccountName into the Password Vault. Error: $(Join-ExceptionMessage $_.Exception)"

AssafMiron commented 3 years ago

Thanks for the explanation @bab29 Now I understand it better :)

I added you suggestion of the LogAccountName to that line, unfortunately adding just that might not help in cases that there are missing mandatory fields as these fields are checked before we set this parameter So I added also the CSV line and moved the setting of that parameter higher in the code so we would have something (even is it has missing parameters) I committed the changes to the DebugWIP branch for now, if you could run a short test to verify that it satisfies this issue that would be great

Thanks, Assaf

On Thu, Apr 15, 2021 at 7:29 PM bab29 @.***> wrote:

[2021-04-13 02:40:36] [INFO] [236/5862] Added successfully. [2021-04-13 02:40:36] [INFO] Skipping onboarding account into the Password Vault. Error: Source:; Message: New-AccountObject: There was an error creating a new account object. ->Source:; Message: Missing mandatory field: Address [2021-04-13 02:40:36] [INFO] Skipping onboarding account into the Password Vault. Error: Source:; Message: New-AccountObject: There was an error creating a new account object. ->Source:; Message: Missing mandatory field: Address [2021-04-13 02:40:36] [INFO] Skipping onboarding account into the Password Vault. Error: Source:; Message: New-AccountObject: There was an error creating a new account object. ->Source:; Message: Missing mandatory field: Address

Above is a copy of a log output and you can see it it doesn't say which account is getting skipped.

It appears the 1638 need to be updated to what I have below or something similar.

Write-LogMessage -Type Info -MSG "Skipping onboarding account $g_LogAccountName into the Password Vault. Error: $(Join-ExceptionMessage $_.Exception)"

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cyberark/epv-api-scripts/issues/179#issuecomment-820564347, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3PN3PNDS34KH3UVJM2BA3TI4H5VANCNFSM423V7K6A .