Octopus.Script exported 2015-01-29 by jasper@sovs.net belongs to ‘NetScaler’ category.
Enables or disables a load balancing service i Citrix NetScaler ADC. For documentation, see https://github.com/jnus/NetScalerPSLib
Parameters
When steps based on the template are included in a project’s deployment process, the parameters below can be set.
Service status
EnableOrDisable = enable
Option whether to disable og enable a Load Balancing Service
LB Service Name
ServiceName =
Load Balancing Service Name to enable or diable
NetScaler ADC host name
HostName =
Address of the primary NetScaler ADC instance
NetScaler ADC username
Username
null
NetScaler ADC password
Password
null
Graceful shutdown
Graceful = Yes
The service is disabled only when all the current active client connections are closed by either the server or the client
Graceful Delay (s)
GracefulDelay = 300
The time in seconds after which the service is marked as OUT OF SERVICE.
Script body
Steps based on this template will execute the following PowerShell script.
param(
[string]$NSAddress,
[string]$ServiceName,
[string]$Action,
[string]$NSUserName,
[string]$NSPassword,
[string]$NSProtocol
)
$ErrorActionPreference = "Stop"
function Connect-NSAppliance {
<#
.SYNOPSIS
Connect to NetScaler Appliance
.DESCRIPTION
Connect to NetScaler Appliance. A custom web request session object will be returned
.PARAMETER NSAddress
NetScaler Management IP address
.PARAMETER NSName
NetScaler DNS name or FQDN
.PARAMETER NSUserName
UserName to access the NetScaler appliance
.PARAMETER NSPassword
Password to access the NetScaler appliance
.PARAMETER Timeout
Timeout in seconds to for the token of the connection to the NetScaler appliance. 900 is the default admin configured value.
.EXAMPLE
$Session = Connect-NSAppliance -NSAddress 10.108.151.1
.EXAMPLE
$Session = Connect-NSAppliance -NSName mynetscaler.mydomain.com
.OUTPUTS
CustomPSObject
.NOTES
Copyright (c) Citrix Systems, Inc. All rights reserved.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory=$true,ParameterSetName='Address')] [string]$NSAddress,
[Parameter(Mandatory=$true,ParameterSetName='Name')] [string]$NSName,
[Parameter(Mandatory=$false)] [string]$NSUserName="nsroot",
[Parameter(Mandatory=$false)] [string]$NSPassword="nsroot",
[Parameter(Mandatory=$false)] [int]$Timeout=900
)
Write-Verbose "$($MyInvocation.MyCommand): Enter"
if ($PSCmdlet.ParameterSetName -eq 'Address') {
Write-Verbose "Validating IP Address"
$IPAddressObj = New-Object -TypeName System.Net.IPAddress -ArgumentList 0
if (-not [System.Net.IPAddress]::TryParse($NSAddress,[ref]$IPAddressObj)) {
throw "'$NSAddress' is an invalid IP address"
}
$nsEndpoint = $NSAddress
} elseif ($PSCmdlet.ParameterSetName -eq 'Name') {
$nsEndpoint = $NSName
}
$login = @{"login" = @{"username"=$NSUserName;"password"=$NSPassword;"timeout"=$Timeout}}
$loginJson = ConvertTo-Json $login
try {
Write-Verbose "Calling Invoke-RestMethod for login"
$response = Invoke-RestMethod -Uri "$($Script:NSURLProtocol)://$nsEndpoint/nitro/v1/config/login" -Body $loginJson -Method POST -SessionVariable saveSession -ContentType application/json
if ($response.severity -eq "ERROR") {
throw "Error. See response: `n$($response | fl * | Out-String)"
} else {
Write-Verbose "Response:`n$(ConvertTo-Json $response | Out-String)"
}
}
catch [Exception] {
throw $_
}
$nsSession = New-Object -TypeName PSObject
$nsSession | Add-Member -NotePropertyName Endpoint -NotePropertyValue $nsEndpoint -TypeName String
$nsSession | Add-Member -NotePropertyName WebSession -NotePropertyValue $saveSession -TypeName Microsoft.PowerShell.Commands.WebRequestSession
Write-Verbose "$($MyInvocation.MyCommand): Exit"
return $nsSession
}
function Set-NSMgmtProtocol {
<#
.SYNOPSIS
Set $Script:NSURLProtocol, this will be used for all subsequent invocation of NITRO APIs
.DESCRIPTION
Set $Script:NSURLProtocol
.PARAMETER Protocol
Protocol, acceptable values are "http" and "https"
.EXAMPLE
Set-Protocol -Protocol https
.NOTES
Copyright (c) Citrix Systems, Inc. All rights reserved.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)] [ValidateSet("http","https")] [string]$Protocol
)
Write-Verbose "$($MyInvocation.MyCommand): Enter"
$Script:NSURLProtocol = $Protocol
Write-Verbose "$($MyInvocation.MyCommand): Exit"
}
function Invoke-NSNitroRestApi {
<#
.SYNOPSIS
Invoke NetScaler NITRO REST API
.DESCRIPTION
Invoke NetScaler NITRO REST API
.PARAMETER NSSession
An existing custom NetScaler Web Request Session object returned by Connect-NSAppliance
.PARAMETER OperationMethod
Specifies the method used for the web request
.PARAMETER ResourceType
Type of the NS appliance resource
.PARAMETER ResourceName
Name of the NS appliance resource, optional
.PARAMETER Action
Name of the action to perform on the NS appliance resource
.PARAMETER Payload
Payload of the web request, in hashtable format
.PARAMETER GetWarning
Switch parameter, when turned on, warning message will be sent in 'message' field and 'WARNING' value is set in severity field of the response in case there is a warning.
Turned off by default
.PARAMETER OnErrorAction
Use this parameter to set the onerror status for nitro request. Applicable only for bulk requests.
Acceptable values: "EXIT", "CONTINUE", "ROLLBACK", default to "EXIT"
.EXAMPLE
Invoke NITRO REST API to add a DNS Server resource.
$payload = @{ip="10.8.115.210"}
Invoke-NSNitroRestApi -NSSession $Session -OperationMethod POST -ResourceType dnsnameserver -Payload $payload -Action add
.OUTPUTS
Only when the OperationMethod is GET:
PSCustomObject that represents the JSON response content. This object can be manipulated using the ConvertTo-Json Cmdlet.
.NOTES
Copyright (c) Citrix Systems, Inc. All rights reserved.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)] [PSObject]$NSSession,
[Parameter(Mandatory=$true)] [ValidateSet("DELETE","GET","POST","PUT")] [string]$OperationMethod,
[Parameter(Mandatory=$true)] [string]$ResourceType,
[Parameter(Mandatory=$false)] [string]$ResourceName,
[Parameter(Mandatory=$false)] [string]$Action,
[Parameter(Mandatory=$false)] [ValidateScript({$OperationMethod -eq "GET"})] [hashtable]$Arguments=@{},
[Parameter(Mandatory=$false)] [ValidateScript({$OperationMethod -ne "GET"})] [hashtable]$Payload=@{},
[Parameter(Mandatory=$false)] [switch]$GetWarning=$false,
[Parameter(Mandatory=$false)] [ValidateSet("EXIT", "CONTINUE", "ROLLBACK")] [string]$OnErrorAction="EXIT"
)
Write-Verbose "$($MyInvocation.MyCommand): Enter"
Write-Verbose "Building URI"
$uri = "$($Script:NSURLProtocol)://$($NSSession.Endpoint)/nitro/v1/config/$ResourceType"
if (-not [string]::IsNullOrEmpty($ResourceName)) {
$uri += "/$ResourceName"
}
if ($OperationMethod -ne "GET") {
if (-not [string]::IsNullOrEmpty($Action)) {
$uri += "?action=$Action"
}
} else {
if ($Arguments.Count -gt 0) {
$uri += "?args="
$argsList = @()
foreach ($arg in $Arguments.GetEnumerator()) {
$argsList += "$($arg.Name):$([System.Uri]::EscapeDataString($arg.Value))"
}
$uri += $argsList -join ','
}
#TODO: Add filter, view, and pagesize
}
Write-Verbose "URI: $uri"
if ($OperationMethod -ne "GET") {
Write-Verbose "Building Payload"
$warning = if ($GetWarning) { "YES" } else { "NO" }
$hashtablePayload = @{}
$hashtablePayload."params" = @{"warning"=$warning;"onerror"=$OnErrorAction;<#"action"=$Action#>}
$hashtablePayload.$ResourceType = $Payload
$jsonPayload = ConvertTo-Json $hashtablePayload -Depth ([int]::MaxValue)
Write-Verbose "JSON Payload:`n$jsonPayload"
}
try {
Write-Verbose "Calling Invoke-RestMethod"
$restParams = @{
Uri = $uri
ContentType = "application/json"
Method = $OperationMethod
WebSession = $NSSession.WebSession
ErrorVariable = "restError"
}
if ($OperationMethod -ne "GET") {
$restParams.Add("Body",$jsonPayload)
}
$response = Invoke-RestMethod @restParams
if ($response) {
if ($response.severity -eq "ERROR") {
throw "Error. See response: `n$($response | fl * | Out-String)"
} else {
Write-Verbose "Response:`n$(ConvertTo-Json $response | Out-String)"
}
}
}
catch [Exception] {
if ($ResourceType -eq "reboot" -and $restError[0].Message -eq "The underlying connection was closed: The connection was closed unexpectedly.") {
Write-Verbose "Connection closed due to reboot"
} else {
throw $_
}
}
Write-Verbose "$($MyInvocation.MyCommand): Exit"
if ($OperationMethod -eq "GET") {
return $response
}
}
$psver = $PSVersionTable.PSVersion.Major
if ($psver -eq "1" -or $psver -eq "2") {
Write-Error "NetScaler ADC Enable Disable Service requires PowerShell v3 or newer. Installed version v$psver"
return -1
}
$NSAddress = $OctopusParameters['HostName']
$NSUserName = $OctopusParameters['Username']
$NSPassword = $OctopusParameters['Password']
$NSProtocol="http"
$Action = $OctopusParameters['EnableOrDisable']
$ServiceName = $OctopusParameters['ServiceName']
$GracefulShutdown = $OctopusParameters['Graceful']
$GraceFulShutdownDelay = $OctopusParameters['GracefulDelay']
if(!$NSAddress) {
Write-Error "No NetScaler address specified. Please specify an address"
exit -2
}
if(!$NSUserName) {
Write-Error "No username specified. Please specify a username"
exit -2
}
if(!$NSPassword) {
Write-Error "No password specified. Please specify a password"
exit -2
}
if(!$Action) {
Write-Error "No action set. Action must either be enable or disable. Please select an action"
exit -2
}
if(!$GracefulShutdown) {
Write-Error "Graceful shutdown not selected. Must either be yes or no. Please select an option"
exit -2
}
if(!$ServiceName) {
Write-Error "Service name must be specified. Please specify service name"
exist -2
}
Set-NSMgmtProtocol -Protocol $NSProtocol
$myNSSession = Connect-NSAppliance -NSAddress $NSAddress -NSUserName $NSUserName -NSPassword $NSPassword
$payload = @{name=$ServiceName}
if($Action -eq "disable") {
$payload = @{name=$ServiceName;graceful=$GracefulShutdown;delay=$GraceFulShutdownDelay}
}
Invoke-NSNitroRestApi -NSSession $myNSSession -OperationMethod POST -ResourceType service -Payload $payload -Action $Action
Provided under the Apache License version 2.0.
To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.
{
"Id": "1bd58988-3e56-4cfb-8f87-3769024fcdc3",
"Name": "NetScaler ADC - Enable or Disable Service",
"Description": "Enables or disables a load balancing service i Citrix NetScaler ADC. For documentation, see https://github.com/jnus/NetScalerPSLib\n",
"Version": 21,
"ExportedAt": "2015-01-29T21:49:10.234+00:00",
"ActionType": "Octopus.Script",
"Author": "jasper@sovs.net",
"Parameters": [
{
"Name": "EnableOrDisable",
"Label": "Service status",
"HelpText": "Option whether to disable og enable a Load Balancing Service",
"DefaultValue": "enable",
"DisplaySettings": {
"Octopus.SelectOptions": "enable|Enable\ndisable|Disable",
"Octopus.ControlType": "Select"
}
},
{
"Name": "ServiceName",
"Label": "LB Service Name",
"HelpText": "Load Balancing Service Name to enable or diable",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "HostName",
"Label": "NetScaler ADC host name",
"HelpText": "Address of the primary NetScaler ADC instance",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "Username",
"Label": "NetScaler ADC username",
"HelpText": null,
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "Password",
"Label": "NetScaler ADC password",
"HelpText": null,
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "Graceful",
"Label": "Graceful shutdown",
"HelpText": "The service is disabled only when all the current active client connections are closed by either the server or the client",
"DefaultValue": "Yes",
"DisplaySettings": {
"Octopus.ControlType": "Select",
"Octopus.SelectOptions": "YES|Yes\nNO|No"
}
},
{
"Name": "GracefulDelay",
"Label": "Graceful Delay (s)",
"HelpText": "The time in seconds after which the service is marked as OUT OF SERVICE.",
"DefaultValue": "300",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
}
],
"Properties": {
"Octopus.Action.Script.ScriptBody": "param(\n [string]$NSAddress,\n [string]$ServiceName,\n [string]$Action,\n [string]$NSUserName,\n [string]$NSPassword,\n [string]$NSProtocol\n)\n\n\n$ErrorActionPreference = \"Stop\"\n\nfunction Connect-NSAppliance {\n <#\n .SYNOPSIS\n Connect to NetScaler Appliance\n .DESCRIPTION\n Connect to NetScaler Appliance. A custom web request session object will be returned\n .PARAMETER NSAddress\n NetScaler Management IP address\n .PARAMETER NSName\n NetScaler DNS name or FQDN\n .PARAMETER NSUserName\n UserName to access the NetScaler appliance\n .PARAMETER NSPassword\n Password to access the NetScaler appliance\n .PARAMETER Timeout\n Timeout in seconds to for the token of the connection to the NetScaler appliance. 900 is the default admin configured value.\n .EXAMPLE\n $Session = Connect-NSAppliance -NSAddress 10.108.151.1\n .EXAMPLE\n $Session = Connect-NSAppliance -NSName mynetscaler.mydomain.com\n .OUTPUTS\n CustomPSObject\n .NOTES\n Copyright (c) Citrix Systems, Inc. All rights reserved.\n #>\n [CmdletBinding()]\n param (\n [Parameter(Mandatory=$true,ParameterSetName='Address')] [string]$NSAddress,\n [Parameter(Mandatory=$true,ParameterSetName='Name')] [string]$NSName,\n [Parameter(Mandatory=$false)] [string]$NSUserName=\"nsroot\",\n [Parameter(Mandatory=$false)] [string]$NSPassword=\"nsroot\",\n [Parameter(Mandatory=$false)] [int]$Timeout=900\n )\n Write-Verbose \"$($MyInvocation.MyCommand): Enter\"\n\n if ($PSCmdlet.ParameterSetName -eq 'Address') {\n Write-Verbose \"Validating IP Address\"\n $IPAddressObj = New-Object -TypeName System.Net.IPAddress -ArgumentList 0\n if (-not [System.Net.IPAddress]::TryParse($NSAddress,[ref]$IPAddressObj)) {\n throw \"'$NSAddress' is an invalid IP address\"\n }\n $nsEndpoint = $NSAddress\n } elseif ($PSCmdlet.ParameterSetName -eq 'Name') {\n $nsEndpoint = $NSName\n }\n\n\n $login = @{\"login\" = @{\"username\"=$NSUserName;\"password\"=$NSPassword;\"timeout\"=$Timeout}}\n $loginJson = ConvertTo-Json $login\n\n try {\n Write-Verbose \"Calling Invoke-RestMethod for login\"\n $response = Invoke-RestMethod -Uri \"$($Script:NSURLProtocol)://$nsEndpoint/nitro/v1/config/login\" -Body $loginJson -Method POST -SessionVariable saveSession -ContentType application/json\n\n if ($response.severity -eq \"ERROR\") {\n throw \"Error. See response: `n$($response | fl * | Out-String)\"\n } else {\n Write-Verbose \"Response:`n$(ConvertTo-Json $response | Out-String)\"\n }\n }\n catch [Exception] {\n throw $_\n }\n\n\n $nsSession = New-Object -TypeName PSObject\n $nsSession | Add-Member -NotePropertyName Endpoint -NotePropertyValue $nsEndpoint -TypeName String\n $nsSession | Add-Member -NotePropertyName WebSession -NotePropertyValue $saveSession -TypeName Microsoft.PowerShell.Commands.WebRequestSession\n\n Write-Verbose \"$($MyInvocation.MyCommand): Exit\"\n\n return $nsSession\n}\n\nfunction Set-NSMgmtProtocol {\n <#\n .SYNOPSIS\n Set $Script:NSURLProtocol, this will be used for all subsequent invocation of NITRO APIs\n .DESCRIPTION\n Set $Script:NSURLProtocol\n .PARAMETER Protocol\n Protocol, acceptable values are \"http\" and \"https\"\n .EXAMPLE\n Set-Protocol -Protocol https\n .NOTES\n Copyright (c) Citrix Systems, Inc. All rights reserved.\n #>\n [CmdletBinding()]\n param (\n [Parameter(Mandatory=$true)] [ValidateSet(\"http\",\"https\")] [string]$Protocol\n )\n\n Write-Verbose \"$($MyInvocation.MyCommand): Enter\"\n\n $Script:NSURLProtocol = $Protocol\n\n Write-Verbose \"$($MyInvocation.MyCommand): Exit\"\n}\n\nfunction Invoke-NSNitroRestApi {\n <#\n .SYNOPSIS\n Invoke NetScaler NITRO REST API\n .DESCRIPTION\n Invoke NetScaler NITRO REST API\n .PARAMETER NSSession\n An existing custom NetScaler Web Request Session object returned by Connect-NSAppliance\n .PARAMETER OperationMethod\n Specifies the method used for the web request\n .PARAMETER ResourceType\n Type of the NS appliance resource\n .PARAMETER ResourceName\n Name of the NS appliance resource, optional\n .PARAMETER Action\n Name of the action to perform on the NS appliance resource\n .PARAMETER Payload\n Payload of the web request, in hashtable format\n .PARAMETER GetWarning\n Switch parameter, when turned on, warning message will be sent in 'message' field and 'WARNING' value is set in severity field of the response in case there is a warning.\n Turned off by default\n .PARAMETER OnErrorAction\n Use this parameter to set the onerror status for nitro request. Applicable only for bulk requests.\n Acceptable values: \"EXIT\", \"CONTINUE\", \"ROLLBACK\", default to \"EXIT\"\n .EXAMPLE\n Invoke NITRO REST API to add a DNS Server resource.\n $payload = @{ip=\"10.8.115.210\"}\n Invoke-NSNitroRestApi -NSSession $Session -OperationMethod POST -ResourceType dnsnameserver -Payload $payload -Action add\n .OUTPUTS\n Only when the OperationMethod is GET:\n PSCustomObject that represents the JSON response content. This object can be manipulated using the ConvertTo-Json Cmdlet.\n .NOTES\n Copyright (c) Citrix Systems, Inc. All rights reserved.\n #>\n [CmdletBinding()]\n param (\n [Parameter(Mandatory=$true)] [PSObject]$NSSession,\n [Parameter(Mandatory=$true)] [ValidateSet(\"DELETE\",\"GET\",\"POST\",\"PUT\")] [string]$OperationMethod,\n [Parameter(Mandatory=$true)] [string]$ResourceType,\n [Parameter(Mandatory=$false)] [string]$ResourceName,\n [Parameter(Mandatory=$false)] [string]$Action,\n [Parameter(Mandatory=$false)] [ValidateScript({$OperationMethod -eq \"GET\"})] [hashtable]$Arguments=@{},\n [Parameter(Mandatory=$false)] [ValidateScript({$OperationMethod -ne \"GET\"})] [hashtable]$Payload=@{},\n [Parameter(Mandatory=$false)] [switch]$GetWarning=$false,\n [Parameter(Mandatory=$false)] [ValidateSet(\"EXIT\", \"CONTINUE\", \"ROLLBACK\")] [string]$OnErrorAction=\"EXIT\"\n )\n\n Write-Verbose \"$($MyInvocation.MyCommand): Enter\"\n\n Write-Verbose \"Building URI\"\n $uri = \"$($Script:NSURLProtocol)://$($NSSession.Endpoint)/nitro/v1/config/$ResourceType\"\n if (-not [string]::IsNullOrEmpty($ResourceName)) {\n $uri += \"/$ResourceName\"\n }\n if ($OperationMethod -ne \"GET\") {\n if (-not [string]::IsNullOrEmpty($Action)) {\n $uri += \"?action=$Action\"\n }\n } else {\n if ($Arguments.Count -gt 0) {\n $uri += \"?args=\"\n $argsList = @()\n foreach ($arg in $Arguments.GetEnumerator()) {\n $argsList += \"$($arg.Name):$([System.Uri]::EscapeDataString($arg.Value))\"\n }\n $uri += $argsList -join ','\n }\n #TODO: Add filter, view, and pagesize\n }\n Write-Verbose \"URI: $uri\"\n\n if ($OperationMethod -ne \"GET\") {\n Write-Verbose \"Building Payload\"\n $warning = if ($GetWarning) { \"YES\" } else { \"NO\" }\n $hashtablePayload = @{}\n $hashtablePayload.\"params\" = @{\"warning\"=$warning;\"onerror\"=$OnErrorAction;<#\"action\"=$Action#>}\n $hashtablePayload.$ResourceType = $Payload\n $jsonPayload = ConvertTo-Json $hashtablePayload -Depth ([int]::MaxValue)\n Write-Verbose \"JSON Payload:`n$jsonPayload\"\n }\n\n try {\n Write-Verbose \"Calling Invoke-RestMethod\"\n $restParams = @{\n Uri = $uri\n ContentType = \"application/json\"\n Method = $OperationMethod\n WebSession = $NSSession.WebSession\n ErrorVariable = \"restError\"\n }\n\n if ($OperationMethod -ne \"GET\") {\n $restParams.Add(\"Body\",$jsonPayload)\n }\n\n $response = Invoke-RestMethod @restParams\n\n if ($response) {\n if ($response.severity -eq \"ERROR\") {\n throw \"Error. See response: `n$($response | fl * | Out-String)\"\n } else {\n Write-Verbose \"Response:`n$(ConvertTo-Json $response | Out-String)\"\n }\n }\n }\n catch [Exception] {\n if ($ResourceType -eq \"reboot\" -and $restError[0].Message -eq \"The underlying connection was closed: The connection was closed unexpectedly.\") {\n Write-Verbose \"Connection closed due to reboot\"\n } else {\n throw $_\n }\n }\n\n Write-Verbose \"$($MyInvocation.MyCommand): Exit\"\n\n if ($OperationMethod -eq \"GET\") {\n return $response\n }\n}\n\n$psver = $PSVersionTable.PSVersion.Major\nif ($psver -eq \"1\" -or $psver -eq \"2\") {\n Write-Error \"NetScaler ADC Enable Disable Service requires PowerShell v3 or newer. Installed version v$psver\"\n return -1\n}\n\n$NSAddress = $OctopusParameters['HostName']\n$NSUserName = $OctopusParameters['Username']\n$NSPassword = $OctopusParameters['Password']\n$NSProtocol=\"http\"\n$Action = $OctopusParameters['EnableOrDisable']\n$ServiceName = $OctopusParameters['ServiceName']\n$GracefulShutdown = $OctopusParameters['Graceful']\n$GraceFulShutdownDelay = $OctopusParameters['GracefulDelay']\n\nif(!$NSAddress) {\n Write-Error \"No NetScaler address specified. Please specify an address\"\n exit -2\n}\n\nif(!$NSUserName) {\n Write-Error \"No username specified. Please specify a username\"\n exit -2\n}\n\nif(!$NSPassword) {\n Write-Error \"No password specified. Please specify a password\"\n exit -2\n}\n\nif(!$Action) {\n Write-Error \"No action set. Action must either be enable or disable. Please select an action\"\n exit -2\n}\n\nif(!$GracefulShutdown) {\n Write-Error \"Graceful shutdown not selected. Must either be yes or no. Please select an option\"\n exit -2\n}\n\nif(!$ServiceName) {\n Write-Error \"Service name must be specified. Please specify service name\"\n exist -2\n}\n\n\nSet-NSMgmtProtocol -Protocol $NSProtocol\n$myNSSession = Connect-NSAppliance -NSAddress $NSAddress -NSUserName $NSUserName -NSPassword $NSPassword\n$payload = @{name=$ServiceName}\nif($Action -eq \"disable\") {\n $payload = @{name=$ServiceName;graceful=$GracefulShutdown;delay=$GraceFulShutdownDelay}\n}\n\nInvoke-NSNitroRestApi -NSSession $myNSSession -OperationMethod POST -ResourceType service -Payload $payload -Action $Action\n",
"Octopus.Action.Script.Syntax": "PowerShell"
},
"Category": "NetScaler",
"HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/netscaler-adc-enable-or-disable-service.json",
"Website": "/step-templates/1bd58988-3e56-4cfb-8f87-3769024fcdc3",
"Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAFYdJREFUeNrsnAl0VFWax+99r5ZUpbKQpEIWtkBIAmHfREfoPkLL5jK206N0q422Otoe7eNx7DNt26PTrY7LGbptWxx6jvax1WYcEbXVQVpFcWURBUG2sARCFsi+1/bunbu8qgSyGJOKhOH/P3UgVB6vXt33u992v/so55xAULxFARYEsCCABQEsjAIEsCCABQEsCAJYEMCCABYEASwIYEEAC4IAFgSwIIAFQQALAlgQwIIggAUBLAhgQRDAggAWBLAgCGBBAAsCWBAEsCCABQEsCAJYEMCCABYEASwIYEEAC4IAFgSwIIAFQQALAlgQwIIggAUBLAhgQRDAggAWBLAgCGBBAAsCWBAEsCCABQEsCAJYEMCCABYEASwIYEEAC4IAFgSwIIAFQQALAlgQwIIggAUBLAh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j1Jny+WxnycNtO3+JDSV1d762t6QuFKsSUzyY9AziLG+BRalzRo7nqe9PnJadKN8yzjawtOUKW/yj0gZh8wnneMTfGa+DijBq4nDPrBEppqGTqEF5UNnggxXtBJGbIzrqcNCZ88D2I6U6QtWz0RVC56phBFgQwIIAFgSwMAoQwIIAFgSwIAhgQQALAlgQBLAggAUBLAgCWBDAggAWBAEsCGBBAAuCABYEsCCABUEACwJYEMCCIIAFASwIYEEQwIIAFgSwIAhgQQALAlgQBLAggAUBLAgCWBDAggAWBAEsCGBBAAuCABYEsCCABUEACwJYEMCCIIAFASwIYEEQwIIAFgSwIAhgQQALAlgQBLAggAUBLAgCWBDAggAWBAEsCGBBAAuCABYEsCCABUEACwJYEMCCIIAFASwIYEEQwIIGV/8nwAB7L6o5TpqM4QAAAABJRU5ErkJggg==",
"$Meta": {
"Type": "ActionTemplate"
}
}
Page updated on Thursday, January 29, 2015