Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions NetScaler/Public/Disable-NSLBServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function Disable-NSLBServer {
Disable the load balancer server 'server01' without confirmation and return the resulting object.

.EXAMPLE
$server = Disable-NSLBServer -Name 'server01' -Graceful 60 -Force -PassThru
$server = Disable-NSLBServer -Name 'server01' -Graceful -Delay 60 -Force -PassThru

Disable the load balancer server 'server01' without confirmation, giving a 60 second grace period before disabling and return the resulting object.

Expand All @@ -49,7 +49,10 @@ function Disable-NSLBServer {
The name or names of the load balancer servers to disable.

.PARAMETER Graceful
Indicates graceful shutdown of the server. System will wait for all outstanding connections to this server to be closed before disabling the server. Wait time in seconds may be included before disabling happens.
Does a graceful shutdown of the server after the number of seconds. System will wait for all outstanding connections to this server to be closed before disabling the server.

.PARAMETER Delay
How many seconds to wait before disabling this server.

.PARAMETER Force
Suppress confirmation when disabling the server.
Expand All @@ -64,6 +67,10 @@ function Disable-NSLBServer {
[parameter(Mandatory,ValueFromPipeline = $true, ValueFromPipelineByPropertyName)]
[string[]]$Name = (Read-Host -Prompt 'LB server name'),

[Parameter(ParameterSetName="Delay")]
[int]$Delay,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the -Graceful and -Delay parameters should be mutually exclusive, e.g. use one or the other? If this is the case, we should introduce the Delay in a separate parameter set.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the code to use parameter sets that makes the Graceful and Delay options mutually exclusive.


[Parameter(ParameterSetName="Graceful")]
[int]$Graceful,

[switch]$Force,
Expand All @@ -84,11 +91,10 @@ function Disable-NSLBServer {
}
if ($PSBoundParameters.ContainsKey('Graceful')) {
$params.Add('graceful', 'YES')
if ($Graceful -gt 0) {
$params.Add('delay', $Graceful)
} else {
$params.Add('delay', 0)
}
$params.Add('delay', $Graceful)
}
if ($PSBoundParameters.ContainsKey('Delay')) {
$params.Add('delay', $Delay)
}
_InvokeNSRestApi -Session $Session -Method POST -Type server -Payload $params -Action disable

Expand Down