Intellisense for PowerShell splatting in vscode?

337 views Asked by At

My understanding is that splatting variables is the preferred/recommended way to make longer function calls in PowerShell scripts. However, I use vscode as my primary IDE and understandably, extracting the parameters into a hashtable and splatting them makes intellisense unusable.

Is there any library/framework/vscode extension for splatting that allows the use of intellisense by way of naming convention or something like that?

2

There are 2 answers

0
anton.burger On

understandably, extracting the parameters into a hashtable and splatting them makes intellisense unusable.

I assumed the same thing recently—and it's likely changed since you first asked the question—but vscode apparently supports intellisense for splatted arguments now. I came looking for information on it (and finding this question) because I was so stunned by seeing suggestions for splatted arguments!

Before

$args here is going to be splatted to New-AzCdnOrigin, but hasn't been yet:

So no suggestions so far:

After

Suggestions from the parameters of New-AzCdnOrigin, even omitting those already added:

1
flagmanchris On

I know this is a relatively old question but whilst looking for similar I came across Editor Services Command Suite which looks like it may be useful. It allows you to write the command out and then convert it to a splatted version: ESCS github repo

It was this blog post by Rob Sewell (sqldbawithabeard) which brought it to my attention: blog post