Wdac.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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
## Wdac module Custom Completers ##

#
# .SYNOPSIS
#
# Complete the -Name arguments to *-OdbcDriver cmdlets
#
function Wdac_OdbcDriverNameParameterCompletion
{
    param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)

    Wdac\Get-OdbcDriver -Name "$wordToComplete*" | Sort-Object Name | ForEach-Object {
        New-CompletionResult $_.Name "Name: $($_.Name)"
    }
}


#
# .SYNOPSIS
#
# Complete the -Name arguments to *-OdbcDsn cmdlets
#
function Wdac_OdbcDsnNameParameterCompletion
{
    param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)

    Wdac\Get-OdbcDsn -Name "$wordToComplete*" | Sort-Object Name | ForEach-Object {
        New-CompletionResult $_.Name "Name: $($_.Name)"
    }
}


#
# .SYNOPSIS
#
# Complete the -DriverName arguments to *-OdbcDsn cmdlets
#
function Wdac_DriverNameParameterCompletion
{
    param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)

    Wdac\Get-OdbcDsn -DriverName "$wordToComplete*" | Sort-Object DriverName | ForEach-Object {
        New-CompletionResult $_.DriverName "DriverName: $($_.DriverName)"
    }
}


Register-ArgumentCompleter `
    -Command ('Get-OdbcDriver','Set-OdbcDriver') `
    -Parameter 'Name' `
    -Description 'Complete the -Name arguments to *-OdbcDriver cmdlets. For example: Get-OdbcDriver -Name <TAB>' `
    -ScriptBlock $function:Wdac_OdbcDriverNameParameterCompletion


Register-ArgumentCompleter `
    -Command ('Add-OdbcDsn','Get-OdbcDsn','Remove-OdbcDsn','Set-OdbcDsn') `
    -Parameter 'Name' `
    -Description 'Complete the -Name arguments to *-OdbcDsn cmdlets. For example: Get-OdbcDsn -Name <TAB>' `
    -ScriptBlock $function:Wdac_OdbcDsnNameParameterCompletion


Register-ArgumentCompleter `
    -Command ('Add-OdbcDsn','Get-OdbcDsn','Remove-OdbcDsn','Set-OdbcDsn') `
    -Parameter 'DriverName' `
    -Description 'Complete the -DriverName arguments to *-OdbcDsn cmdlets. For example: Get-OdbcDsn -DriverName <TAB>' `
    -ScriptBlock $function:Wdac_DriverNameParameterCompletion