Powershell 5.1 variable splatting not working properly with Add-PASSafeMember

Phuc Mai 136 Reputation points
2021-03-24T17:15:13.917+00:00

I'm using this module pspas.pspete.dev, and I try to splat this $groupConfig variable which is a hash table (values in error message below). So running

Add-PASSafeMember @groupConfig

returns this error

Add-PASSafeMember : A positional parameter cannot be found that accepts argument '@{SafeName=Phuc2403_4;
MemberName=SafeAccess_Phuc2403_4_Owner; UseAccounts=True; RetrieveAccounts=True; ListAccounts=True; AddAccounts=True;
UpdateAccountContent=True; UpdateAccountProperties=True; InitiateCPMAccountManagementOperations=True;
SpecifyNextAccountContent=True; RenameAccounts=True; DeleteAccounts=True; UnlockAccounts=True; ManageSafe=True;
ManageSafeMembers=True; BackupSafe=True; ViewAuditLog=True; ViewSafeMembers=True; RequestsAuthorizationLevel=2;
AccessWithoutConfirmation=True; CreateFolders=True; DeleteFolders=True; MoveAccountsAndFolders=True}'.
At line:1 char:1
+ Add-PASSafeMember @groupConfig
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Add-PASSafeMember], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Add-PASSafeMember

Thanks everyone for any suggestion.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,363 questions
0 comments No comments
{count} votes

Accepted answer
  1. Phuc Mai 136 Reputation points
    2021-03-29T08:23:48.36+00:00

    Thanks everyone for you help. It was my fault. The output of ConvertFrom-JSON was not a hashtable, so splatting did not work. You can find online for a cmdlet to convert the output to a hashtable, or in Powershell Core (Powershell version 6 and above) use ConvertFrom-JSON -AsHashtable.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 29,651 Reputation points Microsoft Vendor
    2021-03-25T04:50:05.3+00:00

    Hi,

    As it's a third-party module you can report the issue to the author.
    https://github.com/pspete/psPAS/issues

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

  2. Rich Matheisen 44,776 Reputation points
    2021-03-24T19:10:15.38+00:00

    Did the module writer code for the use of splatted parameters? That's a question you should ask the module's author.