PowerShellWebAccess.ArgumentCompleters.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## PowerShellWebAccess module Custom Completers ##

#
# .SYNOPSIS
#
# Complete the -RuleName argument to *-PswaAuthorizationRule cmdlets
#
function PowerShellWebAccess_PswaAuthorizationRuleNameParameterCompleter
{
    param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)

    PowerShellWebAccess\Get-PswaAuthorizationRule | Where-Object RuleName -like "$wordToComplete*" | Sort-Object RuleName | ForEach-Object{
        New-CompletionResult $_.RuleName "RuleName: $($_.RuleName)"
    }
}


Register-ArgumentCompleter `
    -Command ('Get-PswaAuthorizationRule','Add-PswaAuthorizationRule') `
    -Parameter 'RuleName' `
    -Description 'Complete the -RuleName argument to *-PswaAuthorizationRule cmdlets. For example: Get-PswaAuthorizationRule -RuleName <TAB>' `
    -ScriptBlock $function:PowerShellWebAccess_PswaAuthorizationRuleNameParameterCompleter