NetTCPIP.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
## NetTCPIP module Custom Completers ##

#
# .SYNOPSIS
#
# Complete the -InterfaceAlias arguments to NetTCPIP module cmdlets
#
function NetIPAddressInterfaceAliasParameterCompleter
{
    param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)

    NetTCPIP\Get-NetIPAddress -InterfaceAlias "$wordToComplete*" | Sort-Object InterfaceAlias | ForEach-Object {
        New-CompletionResult $_.InterfaceAlias $_.InterfaceAlias
    }
}


Register-ArgumentCompleter `
    -Command ('Get-NetIPAddress','Get-NetIPConfiguration','Get-NetIPInterface','Get-NetNeighbor','Get-NetRoute','New-NetIPAddress','New-NetNeighbor','New-NetRoute','Remove-NetIPAddress','Remove-NetNeighbor','Remove-NetRoute','Set-NetIPAddress','Set-NetIPInterface','Set-NetNeighbor','Set-NetRoute') `
    -Parameter 'InterfaceAlias' `
    -Description 'Complete InterfaceAlias names, for example: Get-NetIPAddress -InterfaceAlias <TAB>' `
    -ScriptBlock $function:NetIPAddressInterfaceAliasParameterCompleter