Skip to content

Instantly share code, notes, and snippets.

@bielawb
Created October 31, 2016 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bielawb/a0179bc3a83c4866974797a823baa848 to your computer and use it in GitHub Desktop.
Save bielawb/a0179bc3a83c4866974797a823baa848 to your computer and use it in GitHub Desktop.
Same completer, but with parts of it abstracted - all New-*Completer need to be defined first.
param (
[string]$commandName,
[string]$parameterName,
[string]$wordToComplete,
[System.Management.Automation.Language.CommandAst]$commandAst,
[System.Collections.IDictionary]$fakeBoundParameters
)
switch -Regex ($wordToComplete) {
'^(groupType|userAccountControl):$' {
New-MatchingRuleCompleter -Attribute $Matches[1] -Type AndOr
}
'^(member|memberof):$' {
New-MatchingRuleCompleter -Attribute $Matches[1] -Type Chain
}
'^(?!.*=)' {
New-AttributeCompleter -Pattern "$wordToComplete*"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment