Skip to content

Instantly share code, notes, and snippets.

@NoCheroot
Created February 8, 2018 01:45
Show Gist options
  • Select an option

  • Save NoCheroot/d6875b95660d3cc79cbf2326b9e772cc to your computer and use it in GitHub Desktop.

Select an option

Save NoCheroot/d6875b95660d3cc79cbf2326b9e772cc to your computer and use it in GitHub Desktop.
Powershell CompleteInput example
$cmd = "ConvertTo-Json -"
$ret = [System.Management.Automation.CommandCompletion]::MapStringInputToParsedInput($cmd, $cmd.Length)
$candidates = [System.Management.Automation.CommandCompletion]::CompleteInput(
$ret.Item1,
$ret.Item2,
$ret.Item3,
$null,
[System.Management.Automation.PowerShell]::Create()
).CompletionMatches
$candidates | ForEach-Object {
[pscustomobject]@{
CompletionText = $_.CompletionText
ResultType = $_.ResultType.ToString()
ToolTip = $_.ToolTip
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment