Created
September 23, 2022 16:15
-
-
Save mgreenegit/7e090146dfb9677580acc213fc6899e3 to your computer and use it in GitHub Desktop.
POC ARG Completer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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