-
Notifications
You must be signed in to change notification settings - Fork 33
/
NetQos.ArgumentCompleters.ps1
30 lines (25 loc) · 1.07 KB
/
NetQos.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
# ARGUMENT COMPLETER FUNCTIONS #################################################
# NETQOS POLICY NAME
function NetQoS_PolicyNameArgumentCompletion
{
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$optionalCim = @{}
$cim = $fakeBoundParameter["CimSession"]
if($cim)
{
$optionalCim.CimSession = $cim
}
NetQos\Get-NetQosPolicy -Name "$wordToComplete*" @optionalCim |
Sort-Object -Property Name |
ForEach-Object {
$ToolTip = "Name: {0} - Owner: {1} - Throttle Rate: {2:N0} bits/sec" -f $_.Name,$_.Owner,$_.ThrottleRate
New-CompletionResult -CompletionText $_.Name -ToolTip $ToolTip
}
}
# ARGUMENT COMPLETER REGISTRATION ##############################################
# NETQOS POLICY NAME
Register-ArgumentCompleter `
-Command ('Get-NetQosPolicy','Set-NetQosPolicy','Remove-NetQosPolicy') `
-Parameter 'Name' `
-Description 'Complete NetQoS Policy names, for example: Get-NetQosPolicy -Name <TAB>' `
-ScriptBlock $function:NetQoS_PolicyNameArgumentCompletion