Intellisense/InstanceId.Autocompleter.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$ScriptBlock = {
  param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
  $InstanceList = (Get-EC2Instance).Instances | Where-Object -FilterScript {
    $PSItem.Tag.Key -match $wordToComplete -or
      $PSItem.Tag.Value -match $wordToComplete -or
      $PSItem.InstanceId -match $wordToComplete
  }
  $InstanceList.InstanceId
}

$Completer = @{
  CommandName = @(
        'Send-CMSSMPowerShell'
        'Set-CmEc2DnsName'
        'Set-CMEC2InstanceType'
        'Start-CmEc2Instance'
        'Stop-CmEc2InstanceWait'
  )
  ParameterName = 'InstanceId'
  ScriptBlock = $ScriptBlock
}
Register-ArgumentCompleter @Completer