Skip to content

Instantly share code, notes, and snippets.

@bielawb
Created October 31, 2016 23:09
Show Gist options
  • Save bielawb/32aa1edd699ddba64c48dc48f4ae65db to your computer and use it in GitHub Desktop.
Save bielawb/32aa1edd699ddba64c48dc48f4ae65db to your computer and use it in GitHub Desktop.
Module that uses WMF5 completion for skeleton New-JiraIssue
function Get-LoginCompletion {
param(
[string]$commandName,
[string]$parameterName,
[string]$wordToComplete,
[System.Management.Automation.Language.CommandAst]$commandAst,
[System.Collections.IDictionary]$fakeBoundParameters
)
([ADSISearcher]"(&(objectClass=user)(sAMAccountName=$wordToComplete*))").FindAll() |
ForEach-Object {
$user = $_.GetDirectoryEntry()
[System.Management.Automation.CompletionResult]::new(
$user.sAMACcountNAme,
$user.sAMACcountNAme,
[System.Management.Automation.CompletionResultType]::ParameterValue,
"User $($user.Name)"
)
}
}
function New-JiraIssue {
param (
[ArgumentCompleter({Get-LoginCompletion @args})]
[String]$Reporter,
[ArgumentCompleter({Get-LoginCompletion @args})]
[String]$Assignee
)
Write-Warning "Reporter: $Reporter, Assignee: $Assignee"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment