-
Notifications
You must be signed in to change notification settings - Fork 33
/
NetLbfo.ArgumentCompleters.ps1
65 lines (54 loc) · 2.62 KB
/
NetLbfo.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
# ARGUMENT COMPLETER FUNCTIONS #################################################
# NETLBFO TEAM MEMBERS
function NetLBFO_TeamMembersArgumentCompletion
{
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$optionalCim = @{}
$cim = $fakeBoundParameter["CimSession"]
if($cim)
{
$optionalCim.CimSession = $cim
}
NetAdapter\Get-NetAdapter -Name "$wordToComplete*" @optionalCim |
Sort-Object -Property Name |
ForEach-Object {
$ToolTip = "Name: {0} - Status: {1} `nInterface: {2} - Speed: {3}" -f $_.Name,$_.Status,$_.InterfaceDescription,$_.LinkSpeed
New-CompletionResult -CompletionText $_.Name -ToolTip $ToolTip
}
}
# NETLBFO TEAM NAME
function NetLBFO_TeamNameArgumentCompletion
{
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$optionalCim = @{}
$cim = $fakeBoundParameter["CimSession"]
if($cim)
{
$optionalCim.CimSession = $cim
}
NetLbfo\Get-NetLbfoTeam -Name "$wordToComplete*" @optionalCim |
Sort-Object -Property Name |
ForEach-Object {
$ToolTip = "Name: {0} - Status: {1} `nMode: {2} - Algorithm: {3}" -f $_.Name,$_.Status,$_.TeamingMode,$_.LoadBalancingAlgorithm
New-CompletionResult -CompletionText $_.Name -ToolTip $ToolTip
}
}
# ARGUMENT COMPLETER REGISTRATION ##############################################
# NETLBFO TEAM MEMBERS
Register-ArgumentCompleter `
-Command ('New-NetLbfoTeam') `
-Parameter 'TeamMembers' `
-Description 'Complete NetLBFO Team names, for example: New-NetLbfoTeam -Name <name> -TeamMembers <TAB>' `
-ScriptBlock $function:NetLBFO_TeamMembersArgumentCompletion
# NETLBFO TEAM NAME
Register-ArgumentCompleter `
-Command ('Add-NetLbfoTeamMember','Add-NetLbfoTeamNic','Get-NetLbfoTeam','Get-NetLbfoTeamMember','Get-NetLbfoTeamNic','Remove-NetLbfoTeam','Remove-NetLbfoTeamMember','Rename-NetLbfoTeam','Set-NetLbfoTeam','Set-NetLbfoTeamMember','Set-NetLbfoTeamNic') `
-Parameter 'Name' `
-Description 'Complete NetLBFO Team names, for example: Get-NetLbfoTeam -Name <TAB>' `
-ScriptBlock $function:NetLBFO_TeamNameArgumentCompletion
# NETLBFO TEAM NAME
Register-ArgumentCompleter `
-Command ('Add-NetLbfoTeamMember','Add-NetLbfoTeamNic','Get-NetLbfoTeamMember','Get-NetLbfoTeamNic','Remove-NetLbfoTeamMember','Remove-NetLbfoTeamNic','Set-NetLbfoTeamMember','Set-NetLbfoTeamNic') `
-Parameter 'Team' `
-Description 'Complete NetLBFO Team names, for example: Get-NetLbfoTeamNic -Team <TAB>' `
-ScriptBlock $function:NetLBFO_TeamNameArgumentCompletion