Skip to content

Instantly share code, notes, and snippets.

@mgreenegit
Created September 23, 2022 16:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgreenegit/7e090146dfb9677580acc213fc6899e3 to your computer and use it in GitHub Desktop.
Save mgreenegit/7e090146dfb9677580acc213fc6899e3 to your computer and use it in GitHub Desktop.
POC ARG Completer
function smartComplete {
param ( $commandName,
$parameterName,
$wordToComplete,
$commandAst,
$fakeBoundParameters )
$possibleValues = [array](Search-AzGraph -Query "resourcecontainers | where ['type'] == 'microsoft.resources/subscriptions' | project name").name
if ($fakeBoundParameters) {
$return = $possibleValues | Where-Object {$_ -like "$wordToComplete*"}
} else {
$return = $possibleValues | ForEach-Object {$_}
}
return $return
}
function Select-SmartAzSubscription {
param(
[Parameter(Mandatory)]
[ArgumentCompleter({smartComplete @args})]
[String]
$SubscriptionName
)
Select-AzSubscription -SubscriptionName $SubscriptionName
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment