question

PhucMai-8671 avatar image
0 Votes"
PhucMai-8671 asked PhucMai-8671 answered

Powershell 5.1 variable splatting not working properly with Add-PASSafeMember

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

PhucMai-8671 avatar image
0 Votes"
PhucMai-8671 answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered PhucMai-8671 commented

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

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

It works on Powershell Core 7.2 though, so I suppose splatting is supported?

0 Votes 0 ·
IanXue-MSFT avatar image
1 Vote"
IanXue-MSFT answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.