-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix]: Convert init from function to simple execution script
- Initialization is never call as it should be a simple execution script and not a function
- Loading branch information
Showing
1 changed file
with
20 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,23 @@ | ||
function Initialize-PSWinBGP { | ||
<# | ||
.SYNOPSIS | ||
Initialize-PSWinBGP | ||
.DESCRIPTION | ||
Initialize-PSWinBGP | ||
#> | ||
Register-ArgumentCompleter ` | ||
-CommandName Start-WinBGPRoute, Stop-WinBGPRoute, Start-WinBGPRouteMaintenance, Stop-WinBGPRouteMaintenance ` | ||
-ParameterName RouteName -ScriptBlock { | ||
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) | ||
# Define paramaters to $null to avoid syntax errors | ||
$null = $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters | ||
# Initializing PSWinBGP (Command completer is used by some public functions) | ||
Register-ArgumentCompleter ` | ||
-CommandName Start-WinBGPRoute, Stop-WinBGPRoute, Start-WinBGPRouteMaintenance, Stop-WinBGPRouteMaintenance ` | ||
-ParameterName RouteName -ScriptBlock { | ||
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) | ||
# Define paramaters to $null to avoid syntax errors | ||
$null = $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters | ||
|
||
# Dynamically generate routes array | ||
if ($FakeBoundParameters.ComputerName) { | ||
[Array] $routes = (Get-WinBGPRoute -ComputerName $FakeBoundParameters.ComputerName) | ||
} else { | ||
[Array] $routes = (Get-WinBGPRoute) | ||
} | ||
# Return routes as arguments (IntelliSense) | ||
$routes | ForEach-Object { | ||
New-Object -Type System.Management.Automation.CompletionResult -ArgumentList ` | ||
$_.Name, ` | ||
"$(if ($_.ComputerName){"ComputerName: '$($_.ComputerName)' - RouteName: '$($_.Name)'"}else{$_.Name})", ` | ||
"ParameterValue", ` | ||
"$(if ($_.ComputerName){"ComputerName: '$($_.ComputerName)' - "})Network: '$($_.Network)' - Status: '$($_.Status)'" | ||
} | ||
# Dynamically generate routes array | ||
if ($FakeBoundParameters.ComputerName) { | ||
[Array] $routes = (Get-WinBGPRoute -ComputerName $FakeBoundParameters.ComputerName) | ||
} else { | ||
[Array] $routes = (Get-WinBGPRoute) | ||
} | ||
# Return routes as arguments (IntelliSense) | ||
$routes | ForEach-Object { | ||
New-Object -Type System.Management.Automation.CompletionResult -ArgumentList ` | ||
$_.Name, ` | ||
"$(if ($_.ComputerName){"ComputerName: '$($_.ComputerName)' - RouteName: '$($_.Name)'"}else{$_.Name})", ` | ||
"ParameterValue", ` | ||
"$(if ($_.ComputerName){"ComputerName: '$($_.ComputerName)' - "})Network: '$($_.Network)' - Status: '$($_.Status)'" | ||
} | ||
} |