pspete / psPAS

PowerShell module for CyberArk Privileged Access Security REST API
https://pspas.pspete.dev
MIT License
286 stars 90 forks source link

Get-PasUser gives error 500 #464

Closed redboyhun closed 1 year ago

redboyhun commented 1 year ago

Describe the issue

PS M:\> Get-PASUser -Search Prov
Invoke-PASRestMethod : [500] An item with the same key has already been added.
At line:167 char:13
+ ...   $result = Invoke-PASRestMethod -Uri $URI -Method GET -WebSession $S ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: ({"ErrorCode":"C...y been added."}:ErrorRecord) [Invoke-PASRestMethod], Exception
    + FullyQualifiedErrorId : CAWS00001E,Invoke-PASRestMethod

Getting this error, even if that is the first command after psPAS login

Your Environment Include relevant details about your environment

Additional tests Working with specific id:

PS M:\> Get-PASUser -id 3

ID UserName Source   UserType       Suspended enableUser ExpiryDate Location
-- -------- ------   --------       --------- ---------- ---------- --------
3  Auditor  CyberArk Built-InAdmins False     False                 \

Not working for listing all:

PS M:\> Get-PASUser
Invoke-PASRestMethod : [500] An item with the same key has already been added.
At line:167 char:13
+ ...   $result = Invoke-PASRestMethod -Uri $URI -Method GET -WebSession $S ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: ({"ErrorCode":"C...y been added."}:ErrorRecord) [Invoke-PASRestMethod], Exception
    + FullyQualifiedErrorId : CAWS00001E,Invoke-PASRestMethod

Not working with -Username:

PS M:\> Get-PASUser -UserName Auditor
Invoke-PASRestMethod : [500] An item with the same key has already been added.
At line:167 char:13
+ ...   $result = Invoke-PASRestMethod -Uri $URI -Method GET -WebSession $S ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: ({"ErrorCode":"C...y been added."}:ErrorRecord) [Invoke-PASRestMethod], Exception
    + FullyQualifiedErrorId : CAWS00001E,Invoke-PASRestMethod

Working with Username and Gen1API:

PS M:\> Get-PASUser -UserName Auditor -UseGen1API

ID UserName Source   UserTypeName   Suspended Disabled ExpiryDate Location
-- -------- ------   ------------   --------- -------- ---------- --------
   Auditor  Internal Built-InAdmins False     True                \
pspete commented 1 year ago

Hi @redboyhun

Is it working outside of the module? You can use something similar to the below

#after New-PASSession
$ThisSession = Get-PASSession

$Method = "GET"
$UrlPath = "API/Users/"

$Request = @{
    "Method"      = $Method
    "Uri"         = "$($ThisSession.BaseUri)/$UrlPath"
    "WebSession"  = $ThisSession.WebSession
    "ContentType" = "application/json"
}

Invoke-RestMethod @Request
pspete commented 1 year ago

As it is an error of the "500" type, assumption is that it is not an issue with the module. Closing the issue based on this. If assumption incorrect, comment here with the details to reopen.