pspete / psPAS

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

4.5.87 "Set-PASAccount -operations" Error #326

Closed pspete closed 3 years ago

pspete commented 3 years ago

Describe the issue Executing Set-PASAccount while specifying a value for the -operations parameter for updating multiple properties results in an error. Updates to single properties are OK.

To Reproduce Steps to reproduce the behavior:

  1. [array]$ops += @{"op"="replace";"path"="/platformAccountProperties/LogonDomain";"value" ="SomeValue"}
  2. Set-PASAccount -id $id -operations $ops
  3. Error returned: [500] Object reference not set to an instance of an object.

Expected behavior LogonDomain set to SomeValue

Screenshots & Console Output

Console Output Code Block:

Set-PASAccount -id $id -operations $ops
DEBUG: [Body] [
    {
        "operations":  [
                           {
                               "path":  "/platformAccountProperties/LogonDomain",
                               "op":  "replace",
                               "value":  "WinDomain"
                           }
                       ]
    }
]
Invoke-PASRestMethod : [500] Object reference not set to an instance of an object.
At line:240 char:14
+ ...   $Result = Invoke-PASRestMethod -Uri $URI -Method $Method -Body $Bod ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: ({"ErrorCode":"C...of an object."}:ErrorRecord) [Invoke-PASRestMethod], Exception
    + FullyQualifiedErrorId : CAWS00001E,Invoke-PASRestMethod

Your Environment Include relevant details about your environment

Additional context JSON payload for this operation is being sent with an invalid structure. psPAS 4.5.87 includes changes to some ParamterSetNames, however the logic branch which correctly formats the JSON for this type of request was not updated to reference the new ParamterSetNames (on Line 151 V10MultiOp should be Gen2MultiOp) https://github.com/pspete/psPAS/blob/6970ba460c7cd9e3b912d66a9ab7ad3e7c3994e6/psPAS/Functions/Accounts/Set-PASAccount.ps1#L151

šŸ¤¦ Fix incoming