pspete / psPAS

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

Get-PASSafeMember errors when adding parameter MemberName #385

Closed matiya closed 2 years ago

matiya commented 2 years ago

Describe the issue

Running the command: Get-PASSafeMember -SafeName ABC-001

Returns all safe members as intended, for example:

UserName                        SafeName                    Permissions
--------                        --------                    -----------
vaultadmin01                    ACB-0001         @{useAccounts=True; retrieveAccounts=True; listAccounts=True; addAccounts=True; updateAccountCo…

With the -search parameter it works too:

Get-PASSafeMember -safe ABC-001 -search vaultadmin01

UserName     SafeName                    Permissions
--------     --------                    -----------
vaultadmin01 ABC-0001        @{useAccounts=True; retrieveAccounts=True; listAccounts=True; addAccounts=True; updateAccountContent=True; updateA…

But if I add the parameter -MemberName, for instance: Get-PASSafeMember -SafeName ABC-0001 -MemberName vaultadmin01

I get the following error:

MethodInvocationException: 
Line |
 273 |  …             $Members = [Collections.Generic.List[Object]]::New(($resu …
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Exception calling ".ctor" with "1" argument(s): "Value cannot be null. (Parameter 'collection')"

Your Environment Include relevant details about your environment

pspete commented 2 years ago

Thanks for the report @matiya . Issue reproduced in pwsh (issue not present in PowerShell). Fix developed and present in the dev branch.