r/PowerShell • • Apr 05 '19

PowerShell tricks: Splatting

https://blog.destruktive.one/powershell-tricks-splatting/
150 Upvotes

58 comments sorted by

View all comments

Show parent comments

1

u/ka-splam Apr 08 '19

Turns out it behaves differently for cmdlets (but possible not native commands(?)):

PS C:\> function test { $args -join '-' }
PS C:\> $x = @('echo', 'b', 'c')
PS C:\> test $x
System.Object[]
PS C:\> test @x
echo-b-c

Like Python's somefunc(*var) which I've wanted before, so woooo

1

u/TheIncorrigible1 Apr 08 '19

Yes, when used with a cmdlet, it sees that as a single argument