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

2

u/[deleted] Apr 05 '19

[removed] — view removed comment

3

u/Lee_Dailey [grin] Apr 05 '19

howdy Szeraax,

for me, it is building an array of options for robocopy & then using that as the argument list for the util. it apparently works very much like that for other arguments. something like this ...

$RC_Params = @(
    $Source
    $Destination
    $FileSpec 
    # put your current options below
    "/Log:$FullLogFileName"
    '/E'
    '/TEE'
    )

robocopy $RC_Params

it aint what i consider splatting, but it fits well enuf & is documented as such ... but i can't find the silly docs for it right now. [blush]

take care,
lee

4

u/TheIncorrigible1 Apr 05 '19

That's not splatting. You're missing the syntax.

robocopy @RC_Params

2

u/Lee_Dailey [grin] Apr 05 '19

howdy TheIncorrigible1,

as i mentioned - it aint what i consider splatting. [grin] it's all positional or /ArgName:Value stuff. i had not tried it with an @ instead of a $ ... [blush]

take care,
lee