-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
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.
However, when I splat a couple of "common parameters," specifically -Region and -ProfileName, you can see that -Cluster is removed from the Intellisense results.
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 @ECSServiceCheers,
Trevor Sullivan

