Home Dashboard Directory Help
Search

Need a clean way to splat a hashtable against the various commands that take an ArgumentList by Keith Hill MVP


Status: 

Active


10
0
Sign in
to vote
Type: Suggestion
ID: 797536
Opened: 8/15/2013 5:12:38 PM
Access Restriction: Public
0
Workaround(s)
view

Description

There are several commands that have an ArgumentList parameter that take arguments bound for a PowerShell command. However, this parameter doesn't support splatting in any sort of easy and/or obvious way.
Details
Sign in to post a comment.
Posted by Derp McDerp on 12/21/2013 at 4:00 PM
This is kind of a duplicate of:

https://connect.microsoft.com/PowerShell/feedback/details/623344/commands-with-argumentlist-should-have-a-parameter-set-with-parameters-too

See my comment about Perl 6 Parcels for a solution to this problem.
Posted by Jeffery Hicks on 8/15/2013 at 5:47 PM
This is really needed. I ran into this trying to use Invoke-Command to run a script on my machine on a remote machine. It works if parameters are are positional, but then you have to enter all the values with -Argumentlist. This approach fails with named parameters and makes it very difficult to take advantage of default parameter values.
Posted by Keith Hill MVP on 8/15/2013 at 5:25 PM
OK the more I think about this, the more I don't like the -ArgumentList @arglist bit since splatting means apply to the current command (icm in the example above) and not the script being invoked. Hmm, guess the -SplatArguments switch parameter is sounding better to me.
Sign in to post a workaround.