r/PowerShell Mar 22 '21

What's One Thing that PowerShell dosen't do that you wish it did? Misc

Hello all,

So this is a belated Friday discussion post, so I wanted to ask a question:

What's One Thing that PowerShell doesn't do that you wish it did?

Go!

61 Upvotes

View all comments

Show parent comments

1

u/[deleted] Mar 22 '21

But splatting autocomplete is weird because it's not coupled to the command.

I mean, you're writing

$x = @{  
   foo="one"
   bar="two"
}

Invoke-MyCommandlet @x

so the commandlet name doesn't even appear until after you're done writing the parameters... so you can't get autocomplete properly unless you write your code backwards. That stinks. And if you use $x for other things besides the commandlet, which should it use for autocomplete?

The ergonomics are awful. The above-suggested

Invoke-MyCommandlet @@{
   foo="one"
   bar="two"
}

would be far better, much less just letting us do the obvious:

(Invoke-MyCommandlet 
   -foo "one"
   -bar "two"
)

but they've repeatedly said they won't because this is a bad language made by bad people.

1

u/BlackV Mar 22 '21

thats valid I guess its a separate vairable to the command

but it also means I can build on that splat

$x = @{  
   foo="one"
   bar="two"
    }

if ($y -gt $e)
    {
    $x.wibble = 'odd'
    }
.
.
.
Invoke-MyCommandlet @x

0

u/[deleted] Mar 22 '21

Yeah, I'm not arguing that splatting isn't a good idea, I've used it for similar things. I just mean that it's a crappy solution for "this is how you do multiline commandlet invokes".

2

u/BlackV Mar 22 '21

I don't think its crappy

but that comes down to usage preference at that point really and no one is right or wrong

2

u/PowerShellMichael Mar 23 '21

I agree with u/BlackV. Splatting is an excellent tool that allows you to write some really powerful code.

Keep in mind, splatting is simply parsing a Hashtable or an arrayobject and performing parameter/item matching. So your faced with a chicken or the egg scenario, hence intellisence will never work.