Skip to content

Commit f85adbe

Browse files
Merge pull request #1402 from microsoftgraph/fehintolaobafemi/parameter-completers
Microsoft Graph Authentication parameter completers
2 parents f734173 + 7a4d1a0 commit f85adbe

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/Authentication/Authentication/custom/ParameterCompleters.ps1

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Set-StrictMode -Version 2
99
$scopesParameterBlock = {
1010
param($commandName,
1111
$parameterName,
12-
$wordToComplete,
12+
$wordToCompleteScopes,
1313
$commandAst,
1414
$fakeBoundParameters
1515
)
@@ -18,8 +18,25 @@ $scopesParameterBlock = {
1818
$permissionsOAuthQuery = Permissions_GetOauthData (Permissions_GetPermissionsData)
1919
$permissions += $permissionsOAuthQuery.Name
2020
$permissions | Where-Object {
21-
$_ -like "$wordToComplete*"
21+
$_ -like "$wordToCompleteScopes*"
2222
}
2323
}
2424

25-
Register-ArgumentCompleter -CommandName Connect-MgGraph -ParameterName Scopes -ScriptBlock $scopesParameterBlock
25+
$environmentParameterBlock = {
26+
param($commandName,
27+
$parameterName,
28+
$wordToCompleteEnvironment,
29+
$commandAst,
30+
$fakeBoundParameters
31+
)
32+
33+
$environments = Get-MgEnvironment | Select-Object -ExpandProperty Name
34+
$environments | Where-Object {
35+
$_ -like "$wordToCompleteEnvironment*"
36+
}
37+
}
38+
39+
Register-ArgumentCompleter -CommandName Connect-MgGraph -ParameterName Scopes -ScriptBlock $scopesParameterBlock
40+
Register-ArgumentCompleter -CommandName Connect-MgGraph -ParameterName Environment -ScriptBlock $environmentParameterBlock
41+
42+
Register-ArgumentCompleter -CommandName Get-MgEnvironment -ParameterName Name -ScriptBlock $environmentParameterBlock

0 commit comments

Comments
 (0)