Skip to content

Intellisense: Splatting is treated as a positional parameter #3650

@pcgeek86

Description

@pcgeek86

From: PowerShell/vscode-powershell#696

Overview

When splatting parameters onto a command, PowerShell assumes that the splat is taking the place of the first parameter. Therefore, when you attempt to auto-complete parameters, the first parameter is removed from the Intellisense list, even if that parameter doesn't appear in the Splatting HashTable.

For example, take a look at the first parameter of the Amazon Web Services (AWS) Get-ECSClusterService command. The first parameter is -Cluster.

screen shot 2017-04-25 at 3 11 24 pm

However, when I splat a couple of "common parameters," specifically -Region and -ProfileName, you can see that -Cluster is removed from the Intellisense results.

screen shot 2017-04-25 at 3 14 31 pm

When automating against AWS, I use the Intellisense list to build a second Splatting HashTable with service-specific parameters, and then Splat both the common parameters and the service-specific parameters. Hence, the missing parameter causes me a bit of grief. Minor annoyance. :)

### Define common parameters
$Common = @{
  ProfileName = 'awsprofile'
  Region = 'us-west-2'
}

### Define service-specific parameters
$ECSService = @{
  Cluster = $ECSCluster.ClusterName
  ServiceName = 'testservice'
  TaskDefinition = 'windows-test'
  DesiredCount = 1
}

### Splat both common and service-specific parameters
New-ECSService @Common @ECSService

Cheers,
Trevor Sullivan

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions