From 5f3d7b454b0ec9d809e7db1edf63c786d20ade51 Mon Sep 17 00:00:00 2001 From: Herrera Date: Tue, 2 May 2017 21:41:57 -0700 Subject: [PATCH 1/7] added several functions to support additional functionality --- NetScaler/NetScaler.psd1 | 26 +- NetScaler/Public/Add-NSIPResource.ps1 | 53 +- .../Public/Add-NSLBVirtualServerBinding.ps1 | 8 +- NetScaler/Public/Add-NSVLAN.ps1 | 91 ++++ .../Public/Add-NSVLANInterfaceBinding.ps1 | 82 ++++ NetScaler/Public/Disable-NSMode.ps1 | 5 +- NetScaler/Public/Get-NSCertKeyPair.ps1 | 62 +++ NetScaler/Public/Get-NSLBDNSServer.ps1 | 92 ++++ NetScaler/Public/Get-NSVLAN.ps1 | 62 +++ NetScaler/Public/Get-NSVLANBindings.ps1 | 62 +++ NetScaler/Public/New-NSLBServiceGroup.ps1 | 10 +- NetScaler/Public/New-NSLBVirtualServer.ps1 | 38 +- NetScaler/Public/New-NSResponderPolicy.ps1 | 14 +- NetScaler/Public/Remove-NSCertKeyPair.ps1 | 63 +++ NetScaler/Public/Remove-NSDnsNameServer.ps1 | 72 +++ NetScaler/Public/Remove-NSIPResource.ps1 | 101 ++++ NetScaler/Public/Remove-NSLBMonitor.ps1 | 3 +- .../Remove-NSLBServiceGroupMemberBinding.ps1 | 138 ++++++ NetScaler/Public/Remove-NSNTPServer.ps1 | 77 +++ NetScaler/Public/Remove-NSResponderPolicy.ps1 | 64 +++ NetScaler/Public/Remove-NSRewriteAction.ps1 | 69 +++ NetScaler/Public/Remove-NSRewritePolicy.ps1 | 64 +++ NetScaler/Public/Remove-NSVLAN.ps1 | 61 +++ .../Public/Remove-NSVLANInterfaceBinding.ps1 | 80 +++ NetScaler/Public/Set-NSCertKeyPair.ps1 | 122 +++++ NetScaler/Public/Set-NSIPResource.ps1 | 163 +++++++ NetScaler/Public/Set-NSLBMonitor.ps1 | 457 ++++++++++++++++++ NetScaler/Public/Set-NSLBServiceGroup.ps1 | 62 ++- NetScaler/Public/Set-NSLBVirtualServer.ps1 | 41 +- NetScaler/Public/Set-NSNTPServer.ps1 | 99 ++++ NetScaler/Public/Set-NSResponderPolicy.ps1 | 94 ++++ NetScaler/Public/Set-NSRewriteAction.ps1 | 114 +++++ NetScaler/Public/Set-NSRewritePolicy.ps1 | 116 +++++ NetScaler/Public/Set-NSVLAN.ps1 | 90 ++++ 34 files changed, 2683 insertions(+), 72 deletions(-) create mode 100644 NetScaler/Public/Add-NSVLAN.ps1 create mode 100644 NetScaler/Public/Add-NSVLANInterfaceBinding.ps1 create mode 100644 NetScaler/Public/Get-NSCertKeyPair.ps1 create mode 100644 NetScaler/Public/Get-NSLBDNSServer.ps1 create mode 100644 NetScaler/Public/Get-NSVLAN.ps1 create mode 100644 NetScaler/Public/Get-NSVLANBindings.ps1 create mode 100644 NetScaler/Public/Remove-NSCertKeyPair.ps1 create mode 100644 NetScaler/Public/Remove-NSDnsNameServer.ps1 create mode 100644 NetScaler/Public/Remove-NSIPResource.ps1 create mode 100644 NetScaler/Public/Remove-NSLBServiceGroupMemberBinding.ps1 create mode 100644 NetScaler/Public/Remove-NSNTPServer.ps1 create mode 100644 NetScaler/Public/Remove-NSResponderPolicy.ps1 create mode 100644 NetScaler/Public/Remove-NSRewriteAction.ps1 create mode 100644 NetScaler/Public/Remove-NSRewritePolicy.ps1 create mode 100644 NetScaler/Public/Remove-NSVLAN.ps1 create mode 100644 NetScaler/Public/Remove-NSVLANInterfaceBinding.ps1 create mode 100644 NetScaler/Public/Set-NSCertKeyPair.ps1 create mode 100644 NetScaler/Public/Set-NSIPResource.ps1 create mode 100644 NetScaler/Public/Set-NSLBMonitor.ps1 create mode 100644 NetScaler/Public/Set-NSNTPServer.ps1 create mode 100644 NetScaler/Public/Set-NSResponderPolicy.ps1 create mode 100644 NetScaler/Public/Set-NSRewriteAction.ps1 create mode 100644 NetScaler/Public/Set-NSRewritePolicy.ps1 create mode 100644 NetScaler/Public/Set-NSVLAN.ps1 diff --git a/NetScaler/NetScaler.psd1 b/NetScaler/NetScaler.psd1 index 5a1eddf..ddd662e 100644 --- a/NetScaler/NetScaler.psd1 +++ b/NetScaler/NetScaler.psd1 @@ -82,6 +82,8 @@ FunctionsToExport = @( 'Add-NSServerCertificate', 'Add-NSSSLCertificateLink', 'Add-NSSystemFile', + 'Add-NSVLAN', + 'Add-NSVLANInterfaceBinding', 'Add-NSVPNVirtualServerBinding', 'Clear-NSAAASession', 'Clear-NSConfig', @@ -104,6 +106,7 @@ FunctionsToExport = @( 'Get-NSAAAVirtualServer', 'Get-NSAvailableTimeZone', 'Get-NSBackup', + 'Get-NSCertKeyPair', 'Get-NSConfig', 'Get-NSCSAction', 'Get-NSCSPolicy', @@ -148,6 +151,8 @@ FunctionsToExport = @( 'Get-NSSystemFile', 'Get-NSTimeZone', 'Get-NSVersion', + 'Get-NSVLAN', + 'Get-NSVLANBindings', 'Get-NSVPNServer', 'Get-NSVPNSessionPolicy', 'Get-NSVPNSessionProfile', @@ -178,32 +183,51 @@ FunctionsToExport = @( 'New-NSVPNSessionProfile', 'New-NSVPNVirtualServer', 'Remove-NSBackup', + 'Remove-NSCertKeyPair', + 'Remove-NSDnsNameServer', 'Remove-NSDnsSuffix', + 'Remove-NSIPResource', 'Remove-NSLBMonitor', 'Remove-NSLBServer', 'Remove-NSLBServiceGroup', + 'Remove-NSLBServiceGroupMemberBinding', 'Remove-NSLBServiceGroupMonitorBinding', 'Remove-NSLBVirtualServer', 'Remove-NSLBVirtualServerBinding', 'Remove-NSLBSSLVirtualServerProfile', 'Remove-NSLDAPAuthenticationPolicy', 'Remove-NSLDAPAuthenticationServer', + 'Remove-NSNTPServer', 'Remove-NSResponderAction', + 'Remove-NSResponderPolicy', + 'Remove-NSRewritePolicy', + 'Remove-NSRewriteAction', 'Remove-NSSSLCertificateLink', 'Remove-NSSSLProfile', 'Remove-NSSystemFile', + 'Remove-NSVLAN', + 'Remove-NSVLANInterfaceBinding', 'Remove-NSVPNSessionPolicy', 'Remove-NSVPNSessionProfile', 'Restart-NetScaler', + 'Set-NSCertKeyPair', 'Save-NSConfig', 'Set-NSHostname', + 'Set-NSIPResource', + 'Set-NSLBMonitor', 'Set-NSLBServer', 'Set-NSLBServiceGroup', 'Set-NSLBSSLVirtualServer', 'Set-NSLBSSLVirtualServerProfile', 'Set-NSLBVirtualServer', - 'Set-NSResponderAction', + 'Set-NSMode', + 'Set-NSNTPServer', + 'Set-NSResponderAction', + 'Set-NSResponderPolicy', + 'Set-NSRewriteAction', + 'Set-NSRewritePolicy', 'Set-NSSSLProfile', + 'Set-NSVLAN', 'Set-NSTimeZone', 'Set-NSVPNVirtualServerTheme' ) diff --git a/NetScaler/Public/Add-NSIPResource.ps1 b/NetScaler/Public/Add-NSIPResource.ps1 index 5b300a5..e5fb7f0 100644 --- a/NetScaler/Public/Add-NSIPResource.ps1 +++ b/NetScaler/Public/Add-NSIPResource.ps1 @@ -27,6 +27,11 @@ function Add-NSIPResource { Add IP address 10.10.10.10 to NetScaler. + .EXAMPLE + Add-NSIPResource -IPAddress 192.168.30.31 -SubnetMask 255.255.255.0 -Type SNIP -VServer -Telnet -FTP -SNMP -SSH -GUI + + Add IP address 192.168.30.31 to NetScaler and disabled VServer,SSH, GUI and SNMP but enable but enable Telnet and FTP to Netscaler + .PARAMETER Session The NetScaler session object. @@ -66,6 +71,36 @@ function Add-NSIPResource { Default value: ENABLED Possible values = ENABLED, DISABLED + .PARAMETER Telnet + Use this option to set (enable or disable) the virtual server attribute for this IP address. + + Default value: DISABLED + Possible values = ENABLED, DISABLED + + .PARAMETER FTP + Use this option to set (enable or disable) the virtual server attribute for this IP address. + + Default value: DISABLED + Possible values = ENABLED, DISABLED + + .PARAMETER GUI + Use this option to set (enable or disable) the virtual server attribute for this IP address. + + Default value: ENABLED + Possible values = ENABLED, DISABLED + + .PARAMETER SSH + Use this option to set (enable or disable) the virtual server attribute for this IP address. + + Default value: ENABLED + Possible values = ENABLED, DISABLED + + .PARAMETER SNMP + Use this option to set (enable or disable) the virtual server attribute for this IP address. + + Default value: ENABLED + Possible values = ENABLED, DISABLED + .PARAMETER MgmtAccess Allow access to management applications on this IP address. @@ -74,7 +109,6 @@ function Add-NSIPResource { #> [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] param( - [parameter(Mandatory)] $Session = $script:session, [parameter(Mandatory)] @@ -89,6 +123,16 @@ function Add-NSIPResource { [string]$Type = 'SNIP', [switch]$VServer, + + [switch]$Telnet, + + [switch]$FTP, + + [switch]$GUI, + + [switch]$SSH, + + [switch]$SNMP, [switch]$MgmtAccess ) @@ -106,7 +150,12 @@ function Add-NSIPResource { netmask = $SubnetMask type = $Type vserver = if ($PSBoundParameters.ContainsKey('VServer')) { 'ENABLED' } else { 'DISABLED' } - mgmtaccess = if ($PSBoundParameters.ContainsKey('MgmtAccess')) { 'ENABLED' } else { 'DISABLED' } + telnet = if ($PSBoundParameters.ContainsKey('Telnet')) { 'DISABLED' } else { 'DISABLED' } + ftp = if ($PSBoundParameters.ContainsKey('FTP')) { 'DISABLED' } else { 'DISABLED' } + gui = if ($PSBoundParameters.ContainsKey('GUI')) { 'DISABLED' } else { 'ENABLED' } + ssh = if ($PSBoundParameters.ContainsKey('SSH')) { 'DISABLED' } else { 'ENABLED' } + snmp = if ($PSBoundParameters.ContainsKey('SNMP')) { 'DISABLED' } else { 'ENABLED' } + mgmtaccess = if ($PSBoundParameters.ContainsKey('MgmtAccess')) { 'DISABLED' } else { 'ENABLED' } } $response = _InvokeNSRestApi -Session $Session -Method POST -Type nsip -Payload $params -Action add } catch { diff --git a/NetScaler/Public/Add-NSLBVirtualServerBinding.ps1 b/NetScaler/Public/Add-NSLBVirtualServerBinding.ps1 index 5379b04..664eb82 100644 --- a/NetScaler/Public/Add-NSLBVirtualServerBinding.ps1 +++ b/NetScaler/Public/Add-NSLBVirtualServerBinding.ps1 @@ -70,11 +70,11 @@ function Add-NSLBVirtualServerBinding { [parameter(Mandatory)] [string]$VirtualServerName = (Read-Host -Prompt 'LB virtual server name'), - [parameter(Mandatory, ParameterSetName='servicegroup')] - [string]$ServiceGroupName, + [parameter(ParameterSetName='servicegroup')] + [string]$ServiceGroupName = $null, - [parameter(Mandatory, ParameterSetName='serviceservice')] - [string]$ServiceName, + [parameter(ParameterSetName='serviceservice')] + [string]$ServiceName = $null, [ValidateRange(1, 100)] [int]$Weight = 1, diff --git a/NetScaler/Public/Add-NSVLAN.ps1 b/NetScaler/Public/Add-NSVLAN.ps1 new file mode 100644 index 0000000..edf04fe --- /dev/null +++ b/NetScaler/Public/Add-NSVLAN.ps1 @@ -0,0 +1,91 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Add-NSVLAN { + <# + .SYNOPSIS + Add an untagged/unbound VLAN to NetScaler appliance. + + .DESCRIPTION + Add an untagged/unbound VLAN to NetScaler appliance. + + .EXAMPLE + Add-NSVLAN -VLANID 150 -AliasName 'testvlan' -MTU 1500 + + Adds VLAN 150 with an alias name of 'testvlan' with a MTU of 1500 to the NetScaler appliance. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VLANID + A positive integer that uniquely identifies a VLAN. + + .PARAMETER AliasName + A name for the VLAN. Must begin with a letter, a number, or the underscore symbol, and can consist of from 1 to 31 letters, numbers, and the hyphen (-), period (.) pound (#), space ( ), at sign (@), equals (=), colon (:), and underscore (_) characters. + + .PARAMETER IPV6DynamicRouting + Enable all IPv6 dynamic routing protocols on this VLAN. Note: For the ENABLED setting to work, you must configure IPv6 dynamic routing protocols from the VTYSH command line. Possible values = ENABLED, DISABLED + + .PARAMETER MTU + Specifies the maximum transmission unit (MTU), in bytes. + + .PARAMETER Force + Suppress confirmation when adding a DNS suffix. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')] + param ( + $Session = $script:session, + + [parameter(Mandatory, ValueFromPipeline)] + [int]$VLANID, + + [parameter(Mandatory, ValueFromPipeline)] + [string[]]$AliasName, + + [parameter()] + [ValidateSet('ENABLED', 'DISABLED')] + [string[]]$IPV6DynamicRouting = 'DISABLED', + + [parameter()] + [int]$MTU = 1500, + + [Switch]$Force + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $VLANID) { + if ($PSCmdlet.ShouldProcess($item, 'Add VLAN suffix')) { + try { + $params = @{ + id = $item + aliasname = $AliasName + ipv6dynamicrouting = $IPV6DynamicRouting + mtu = $MTU + + } + $response = _InvokeNSRestApi -Session $Session -Method POST -Type vlan -Payload $params -Action add + } + catch { + throw $_ + } + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Add-NSVLANInterfaceBinding.ps1 b/NetScaler/Public/Add-NSVLANInterfaceBinding.ps1 new file mode 100644 index 0000000..2f096d8 --- /dev/null +++ b/NetScaler/Public/Add-NSVLANInterfaceBinding.ps1 @@ -0,0 +1,82 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Add-NSVLANInterfaceBinding { + <# + .SYNOPSIS + Binds a VLAN to an interface and tags/untags to NetScaler appliance. + + .DESCRIPTION + Binds a VLAN to an interface and tags/untags to NetScaler appliance. + + .EXAMPLE + Add-NSVLANInterfaceBinding -VLANID 150 -Interface '0/1' -Tagged + + Binds VLAN 150 to interface '0/1' and tags it on the NetScaler appliance. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VLANID + A positive integer that uniquely identifies a VLAN. + + .PARAMETER Interface + The interface to be bound to the VLAN, specified in slot/port notation (for example, 1/3). + + .PARAMETER Tagged + Make the interface an 802.1q tagged interface. + + .PARAMETER Force + Suppress confirmation when adding a DNS suffix. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')] + param ( + $Session = $script:session, + + [parameter(Mandatory, ValueFromPipeline)] + [string[]]$VLANID, + + [parameter(Mandatory, ValueFromPipeline)] + [string[]]$Interface, + + [parameter(Mandatory)] + [switch]$Tagged, + + [switch]$Force + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $VLANID) { + if ($PSCmdlet.ShouldProcess($item, 'Add VLAN Binding')) { + try { + $params = @{ + id = $item + ifnum = $Interface + tagged = $Tagged.ToBool() + } + $response = _InvokeNSRestApi -Session $Session -Method PUT -Type vlan_interface_binding -Payload $params -Action add + } + catch { + throw $_ + } + } + } + } +} diff --git a/NetScaler/Public/Disable-NSMode.ps1 b/NetScaler/Public/Disable-NSMode.ps1 index e2ccbdc..e5a65f6 100644 --- a/NetScaler/Public/Disable-NSMode.ps1 +++ b/NetScaler/Public/Disable-NSMode.ps1 @@ -49,10 +49,7 @@ function Disable-NSMode { $Session = $script:session, [parameter(Mandatory,ValueFromPipeline = $true, ValueFromPipelineByPropertyName)] - [ValidateSet( - 'bridgebpbus', 'cka', 'dradv', 'dradv6', 'edge', 'fr', 'iradv', 'l2', 'l3', 'mbf', - 'pmtud', 'rise_apbr', 'rise_rhi', 'sradv', 'sradv6', 'tcpb', 'usip', 'usnip' - )] + [ValidateSet('bridgebpbus', 'cka', 'dradv', 'dradv6', 'edge', 'fr', 'iradv', 'l2', 'l3', 'mbf','pmtud', 'rise_apbr', 'rise_rhi', 'sradv', 'sradv6', 'tcpb', 'usip', 'usnip')] [string[]]$Name = (Read-Host -Prompt 'Netscaler mode'), [switch]$Force, diff --git a/NetScaler/Public/Get-NSCertKeyPair.ps1 b/NetScaler/Public/Get-NSCertKeyPair.ps1 new file mode 100644 index 0000000..08010f9 --- /dev/null +++ b/NetScaler/Public/Get-NSCertKeyPair.ps1 @@ -0,0 +1,62 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Get-NSCertKeyPair { + <# + .SYNOPSIS + Retrieve server certificate from NetScaler appliance. + + .DESCRIPTION + Retrieve server certificate from NetScaler appliance. + + .EXAMPLE + Get-NSCertKeyPair -CertKeyName 'myrootCA' + + Retrieves a root certificate key pair named 'myrootCA' located on the appliance. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER CertKeyName + Name for the certificate and private-key pair. Must begin with an ASCII alphanumeric or underscore (_) character, + and must contain only ASCII alphanumeric, underscore, hash (#), period (.), space, colon (:), at (@), equals (=), + and hyphen (-) characters. Cannot be changed after the certificate-key pair is created. The following requirement + applies only to the NetScaler CLI: If the name includes one or more spaces, enclose the name in double or single + quotation marks (for example, "my cert" or 'my cert'). + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [Parameter(Mandatory)] + [string]$CertKeyName + ) + + begin { + _AssertSessionActive + } + + process { + if ($PSCmdlet.ShouldProcess($CertKeyName, 'Retrieve SSL certificate and private key pair')) { + try { + $response = _InvokeNSRestApi -Session $Session -Method GET -Type sslcertkey -Resource $CertKeyName -Action get + $response.sslcertkey + } catch { + throw $_ + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Get-NSLBDNSServer.ps1 b/NetScaler/Public/Get-NSLBDNSServer.ps1 new file mode 100644 index 0000000..bc299d2 --- /dev/null +++ b/NetScaler/Public/Get-NSLBDNSServer.ps1 @@ -0,0 +1,92 @@ +<# +Copyright 2015 Brandon Olin + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Get-NSLBDNSServer { + <# + .SYNOPSIS + Gets the specified load balancer virtual server object. + + .DESCRIPTION + Gets the specified load balancer virtual server object. + + .EXAMPLE + Get-NSLBVirtualServer + + Get all load balancer virtual server objects. + + .EXAMPLE + Get-NSLBVirtualServer -Name 'vserver01' + + Get the load balancer virtual server named 'vserver01'. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER Name + The name or names of the load balancer virtual server to get. + + .PARAMETER Port + Filter load balancer virtual servers by port. + + .PARAMETER ServiceType + Filter load balancer virtual servers by service type. + + .PARAMETER LBMethod + Filter load balancer virtual servers by load balancing method. + #> + [cmdletbinding()] + param( + $Session = $script:session, + + [Parameter(Position=0)] + [string]$filter + + ) + + begin { + _AssertSessionActive + $response = @() + } + + process { + # Contruct a filter hash if we specified any filters + $filters = @{} + if ($PSBoundParameters.ContainsKey('ip')) { + $filters.'ip' = $Name + } + if ($PSBoundParameters.ContainsKey('Port')) { + $filters.'port' = $Port + } + if ($PSBoundParameters.ContainsKey('ServiceType')) { + $filters.'servicetype' = $ServiceType + } + if ($PSBoundParameters.ContainsKey('LBMethod')) { + $filters.'lbmethod' = $LBMethod + } + + # If we specified any filters, filter based on them + # Otherwise, get everything + if ($filters.count -gt 0) { + $response = _InvokeNSRestApi -Session $Session -Method Get -Type lbvserver -Action Get -Filters $filters + } else { + $response = _InvokeNSRestApi -Session $Session -Method Get -Type lbvserver -Action Get + } + if ($response.errorcode -ne 0) { throw $response } + if ($response.psobject.properties | where name -eq lbvserver) { + return $response.lbvserver + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Get-NSVLAN.ps1 b/NetScaler/Public/Get-NSVLAN.ps1 new file mode 100644 index 0000000..36b707b --- /dev/null +++ b/NetScaler/Public/Get-NSVLAN.ps1 @@ -0,0 +1,62 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Get-NSVLAN { + <# + .SYNOPSIS + Retrieves an untagged/unbound VLAN information from the NetScaler appliance. + + .DESCRIPTION + Retrieves an untagged/unbound VLAN information from the NetScaler appliance. + + .EXAMPLE + Get-NSVLAN -VLANID 150 + + Retrieves the information for VLANID 150 from the NetScaler appliance. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VLANID + A positive integer that uniquely identifies a VLAN. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')] + param ( + $Session = $script:session, + + [parameter(Mandatory, ValueFromPipeline)] + [string[]]$VLANID + + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $VLANID) { + if ($PSCmdlet.ShouldProcess($item, 'Get VLAN information')) { + try { + $t = _InvokeNSRestApi -Session $Session -Method GET -Type vlan -Resource $item -Action get + $t.vlan + } + catch { + throw $_ + } + } + } + } +} diff --git a/NetScaler/Public/Get-NSVLANBindings.ps1 b/NetScaler/Public/Get-NSVLANBindings.ps1 new file mode 100644 index 0000000..915564e --- /dev/null +++ b/NetScaler/Public/Get-NSVLANBindings.ps1 @@ -0,0 +1,62 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Get-NSVLANBindings { + <# + .SYNOPSIS + Retrieves an untagged/unbound VLAN information from the NetScaler appliance. + + .DESCRIPTION + Retrieves an untagged/unbound VLAN information from the NetScaler appliance. + + .EXAMPLE + Get-NSVLAN -VLANID 150 + + Retrieves the information for VLANID 150 from the NetScaler appliance. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VLANID + A positive integer that uniquely identifies a VLAN. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')] + param ( + $Session = $script:session, + + [parameter(Mandatory, ValueFromPipeline)] + [string[]]$VLANID + + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $VLANID) { + if ($PSCmdlet.ShouldProcess($item, 'Get VLAN information')) { + try { + $t = _InvokeNSRestApi -Session $Session -Method GET -Type vlan_binding -Resource $item -Action get + $t.vlan_binding | fl + } + catch { + throw $_ + } + } + } + } +} diff --git a/NetScaler/Public/New-NSLBServiceGroup.ps1 b/NetScaler/Public/New-NSLBServiceGroup.ps1 index 10a17c3..5769208 100644 --- a/NetScaler/Public/New-NSLBServiceGroup.ps1 +++ b/NetScaler/Public/New-NSLBServiceGroup.ps1 @@ -132,7 +132,7 @@ function New-NSLBServiceGroup { value set by the set ns config command is used as client's IP header name. Minimum length = 1 - .PARAMETER MaxBandwithKbps + .PARAMETER MaxBandwidthKbps Maximum bandwidth, in Kbps, allocated for all the services in the service group. Minimum value = 0 Maximum value = 4294967287 @@ -179,7 +179,7 @@ function New-NSLBServiceGroup { [string]$ServiceType = 'HTTP', [ValidateRange(0, 4094)] - [int]$TrafficDomainId, + [int]$TrafficDomainId = 0, [ValidateSet('SERVER', 'FORWARD', 'TRANSPARENT', 'REVERSE')] [string]$CacheType, @@ -232,7 +232,7 @@ function New-NSLBServiceGroup { [string]$ClientIPHeader, [ValidateRange(0, 4294967287)] - [int]$MaxBandwithKbps, + [int]$MaxBandwidthKbps, [ValidateRange(0, 65535)] [int]$MonitorThreshold, @@ -292,8 +292,8 @@ function New-NSLBServiceGroup { if ($ClientIP -eq 'ENABLED') { $params.Add('cipheader', $ClientIPHeader) } - if ($PSBoundParameters.ContainsKey('MaxBandwithKbps')) { - $params.Add('maxbandwidth', $MaxBandwithKbps) + if ($PSBoundParameters.ContainsKey('MaxBandwidthKbps')) { + $params.Add('maxbandwidth', $MaxBandwidthKbps) } if ($PSBoundParameters.ContainsKey('MonitorThreshold')) { $params.Add('monthreshold', $MonitorThreshold) diff --git a/NetScaler/Public/New-NSLBVirtualServer.ps1 b/NetScaler/Public/New-NSLBVirtualServer.ps1 index 0537f02..4e8edb4 100644 --- a/NetScaler/Public/New-NSLBVirtualServer.ps1 +++ b/NetScaler/Public/New-NSLBVirtualServer.ps1 @@ -109,15 +109,10 @@ function New-NSLBVirtualServer { * FIXSESSION - Connections that have the same SenderCompID and TargetCompID values belong to the same persistence session. Possible values = SOURCEIP, COOKIEINSERT, SSLSESSION, RULE, URLPASSIVE, CUSTOMSERVERID, DESTIP, SRCIPDESTIP, CALLID, RTSPSID, DIAMETER, FIXSESSION, NONE - .PARAMETER RedirectFromPort - Port number for the virtual server, from which we absorb the traffic for http redirect. - Minimum value = 1 - Range 1 - 65535 - .PARAMETER HTTPSRedirectURL URL to which to redirect traffic if the traffic is recieved from redirect port. - .PARAMETER ICMPVSResponse + .PARAMETER ICMPVSRResponse How the NetScaler appliance responds to ping requests received for an IP address that is common to one or more virtual servers. Available settings function as follows: * If set to PASSIVE on all the virtual servers that share the IP address, the appliance always responds to the ping requests. * If set to ACTIVE on all the virtual servers that share the IP address, the appliance responds to the ping requests if at least one of the virtual servers is UP. Otherwise, the appliance does not respond. @@ -164,22 +159,16 @@ function New-NSLBVirtualServer { $PersistenceType, [Parameter()] - [ValidateRange(1, 65535)] - [int] - $RedirectFromPort, - - [Parameter()] + [ValidateSet('PASSIVE', 'ACTIVE')] [string] - $HTTPSRedirectURL, + $ICMPVSRResponse = 'PASSIVE', [Parameter()] - [ValidateSet('PASSIVE', 'ACTIVE')] [string] - $ICMPVSResponse = 'PASSIVE', + $HTTPRedirectURL, [Parameter()] - [int] - $Timeout, + [int]$TimeOut = 2, [Switch]$PassThru ) @@ -199,24 +188,17 @@ function New-NSLBVirtualServer { ipv46 = $IPAddress port = $Port lbmethod = $LBMethod - icmpvsrresponse = $ICMPVSResponse + icmpvsrresponse = $ICMPVSRResponse + timeout = $TimeOut } if ($PSBoundParameters.ContainsKey('PersistenceType')) { $params.Add('persistencetype', $PersistenceType) } - if ($PSBoundParameters.ContainsKey('RedirectFromPort')) { - $params.Add('redirectfromport', $RedirectFromPort) - } - - if ($PSBoundParameters.ContainsKey('HTTPSRedirectURL')) { - $params.Add('httpsredirecturl', $HTTPSRedirectURL) - } - - if ($PSBoundParameters.ContainsKey('Timeout')) { - $params.Add('timeout', $Timeout) - } + if ($PSBoundParameters.ContainsKey('HTTPRedirectURL')) { + $params.Add('redirurl', $HTTPRedirectURL) + } _InvokeNSRestApi -Session $Session -Method POST -Type lbvserver -Payload $params -Action add diff --git a/NetScaler/Public/New-NSResponderPolicy.ps1 b/NetScaler/Public/New-NSResponderPolicy.ps1 index 4230a46..5ffb368 100644 --- a/NetScaler/Public/New-NSResponderPolicy.ps1 +++ b/NetScaler/Public/New-NSResponderPolicy.ps1 @@ -23,7 +23,7 @@ function New-NSResponderPolicy { Adds a responder policy. .EXAMPLE - New-NSResponderPolicy -Name 'act-redirect' -Ruke 'HTTP.REQ.URL.EQ("/")' -Action 'Redirect act' + New-NSResponderPolicy -Name 'act-redirect' -Rule 'HTTP.REQ.URL.EQ("/")' -Action 'Redirect act' Creates a new responder policy which uses the 'Redirect act' responder action @@ -42,6 +42,9 @@ function New-NSResponderPolicy { * RESET - Reset the client connection by closing it. The client program, such as a browser, will handle this and may inform the user. The client may then resend the request if desired. * DROP - Drop the request without sending a response to the user. + .PARAMETER Comment + Adds a comment to the Responder Policy. + .PARAMETER Passthru Return the newly created responder policy. #> @@ -53,12 +56,13 @@ function New-NSResponderPolicy { [string[]]$Name, [Parameter(Mandatory=$True)] - [string] - $Rule, + [string]$Rule, [Parameter(Mandatory=$True)] - [string] - $Action, + [string]$Action, + + [Parameter()] + [string]$Comment, [Switch]$PassThru ) diff --git a/NetScaler/Public/Remove-NSCertKeyPair.ps1 b/NetScaler/Public/Remove-NSCertKeyPair.ps1 new file mode 100644 index 0000000..0943332 --- /dev/null +++ b/NetScaler/Public/Remove-NSCertKeyPair.ps1 @@ -0,0 +1,63 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Remove-NSCertKeyPair { + <# + .SYNOPSIS + Remove server certificate from NetScaler appliance. + + .DESCRIPTION + Remove server certificate from NetScaler appliance. + + .EXAMPLE + Remove-NSCertKeyPair -CertKeyName 'myrootCA' + + Removes a root certificate key pair named 'myrootCA' from the appliance. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER Force + Suppress confirmation removing certificate binding + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [Parameter()] + [string]$CertKeyName, + + [Switch]$Force + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $CertKeyName) { + if ($Force -or $PSCmdlet.ShouldProcess($item, 'Remove certificate')) { + try { + + _InvokeNSRestApi -Session $Session -Method DELETE -Type sslcertkey -Resource $item -Action delete + + } catch { + throw $_ + } + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Remove-NSDnsNameServer.ps1 b/NetScaler/Public/Remove-NSDnsNameServer.ps1 new file mode 100644 index 0000000..87a5a30 --- /dev/null +++ b/NetScaler/Public/Remove-NSDnsNameServer.ps1 @@ -0,0 +1,72 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Remove-NSDnsNameServer { + <# + .SYNOPSIS + Remove a domain name server from NetScaler appliance. + + .DESCRIPTION + Remove a domain name server from NetScaler appliance. + + .EXAMPLE + Remove-NSDnsNameServer -IPAddress '8.8.8.8' + + Remove DNS server IP 8.8.8.8 from NetScaler. + + .EXAMPLE + '2.2.2.2', '8.8.8.8' | Remove-NSDnsNameServer -Session $session + + Removes DNS servers with IPs 2.2.2.2 and 8.8.8.8 from NetScaler using the pipeline. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER IPAddress + IP address of an external name server or, if the Local parameter is set, IP address of a local DNS server (LDNS). + + .PARAMETER Force + Suppress confirmation adding certificate binding + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [parameter()] + # [ValidateScript({$_ -match [IPAddress]$_ })] + [string[]]$IPAddress = (Read-Host -Prompt 'DNS server IP'), + + [Switch]$Force + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $IPAddress) { + if ($Force -or $PSCmdlet.ShouldProcess($item, 'Remove DNS server IP')) { + try { + + _InvokeNSRestApi -Session $Session -Method DELETE -Type dnsnameserver -Resource $item -Action delete + + } catch { + throw $_ + } + } + } + } +} diff --git a/NetScaler/Public/Remove-NSIPResource.ps1 b/NetScaler/Public/Remove-NSIPResource.ps1 new file mode 100644 index 0000000..0ae2c04 --- /dev/null +++ b/NetScaler/Public/Remove-NSIPResource.ps1 @@ -0,0 +1,101 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Remove-NSIPResource { + <# + .SYNOPSIS + Remove an IP resource to the NetScaler appliance. + + .DESCRIPTION + Remove an IP resource to the NetScaler appliance. + + .EXAMPLE + Remove-NSIPResource -IPAddress '10.10.10.10' -SubNetMask '255.255.255.0' + + Removes IP address 10.10.10.10 to NetScaler. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER IPAddress + IPv4 address to create on the NetScaler appliance. + + Note: Cannot be changed after the IP address is created + + .PARAMETER SubnetMask + Subnet mask associated with the IP address. + + .PARAMETER Type + Type of the IP address to create on the NetScaler appliance. Cannot be changed after the IP address is created. + + The following are the different types of NetScaler owned IP addresses: + + * A Subnet IP (SNIP) address is used by the NetScaler ADC to communicate with the servers. + The NetScaler also uses the subnet IP address when generating its own packets, such as packets related to dynamic routing + protocols, or to send monitor probes to check the health of the servers. + + * A Virtual IP (VIP) address is the IP address associated with a virtual server. It is the IP address to which clients connect. + An appliance managing a wide range of traffic may have many VIPs configured. Some of the attributes of the VIP address are + customized to meet the requirements of the virtual server. + + * A GSLB site IP (GSLBIP) address is associated with a GSLB site. It is not mandatory to specify a GSLBIP address when you + initially configure the NetScaler appliance. A GSLBIP address is used only when you create a GSLB site. + + * A Cluster IP (CLIP) address is the management address of the cluster. All cluster configurations must be performed by + accessing the cluster through this IP address. + + Default value: SNIP + Possible values = SNIP, VIP, NSIP, GSLBsiteIP, CLIP + + .PARAMETER VServer + Use this option to set (enable or disable) the virtual server attribute for this IP address. + + Default value: ENABLED + Possible values = ENABLED, DISABLED + + .PARAMETER MgmtAccess + Allow access to management applications on this IP address. + + Default value: DISABLED + Possible values = ENABLED, DISABLED + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [parameter(Mandatory)] + [ValidateScript({$_ -match [IPAddress]$_ })] + [string[]]$IPAddress = (Read-Host -Prompt 'IP resource'), + + [switch]$Force + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $IPAddress) { + if ($Force -or $PSCmdlet.ShouldProcess($item, 'Remove IP resource')) { + try { + _InvokeNSRestApi -Session $Session -Method DELETE -Type nsip -Resource $item -Action delete + } catch { + throw $_ + } + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Remove-NSLBMonitor.ps1 b/NetScaler/Public/Remove-NSLBMonitor.ps1 index 1d1096a..7443388 100644 --- a/NetScaler/Public/Remove-NSLBMonitor.ps1 +++ b/NetScaler/Public/Remove-NSLBMonitor.ps1 @@ -60,9 +60,8 @@ function Remove-NSLBMonitor { foreach ($item in $Name) { if ($Force -or $PSCmdlet.ShouldProcess($item, 'Delete Monitor')) { try { - $m = Get-NSLBMonitor -Session $Session -Name $item $params = @{ - type = $m.type + monitorname = $Name } _InvokeNSRestApi -Session $Session -Method DELETE -Type lbmonitor -Resource $item -Arguments $params -Action delete } catch { diff --git a/NetScaler/Public/Remove-NSLBServiceGroupMemberBinding.ps1 b/NetScaler/Public/Remove-NSLBServiceGroupMemberBinding.ps1 new file mode 100644 index 0000000..67fbf29 --- /dev/null +++ b/NetScaler/Public/Remove-NSLBServiceGroupMemberBinding.ps1 @@ -0,0 +1,138 @@ +<# +Copyright 2015 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Remove-NSLBServiceGroupMemberBinding { + <# + .SYNOPSIS + Disassociates a load balancer server to a service group. + + .DESCRIPTION + Disassociates a load balancer server to a service group. + + .EXAMPLE + Remove-NSLBServiceGroupMember -Name 'sg01' -ServerName 'server01' + + Disassociates server 'server01' from service group 'sg01' + + .EXAMPLE + $x = Remove-NSLBServiceGroupMember -Name 'sg01' -ServerName 'server01' -State 'DISABLED' -PassThru + + Associates server 'server01' with service group 'sg01' initially in a DISABLED state and return the object. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER Name + The name of the service group to associated the server with. + + .PARAMETER ServerName + Name of the server to which to bind the service group. + + .PARAMETER IPAddress + IP Address of the server/resource. + + .PARAMETER Port + Server port number. + + Range 1 - 65535 + + .PARAMETER Weight + Weight to assign to the servers in the service group. + Specifies the capacity of the servers relative to the other servers in the load balancing configuration. + The higher the weight, the higher the percentage of requests sent to the service. + + Minimum value = 1 + Maximum value = 100 + + .PARAMETER ServerId + The identifier for the service. This is used when the persistency type is set to Custom Server ID. + + .PARAMETER HashId + The hash identifier for the service. This must be unique for each service. + This parameter is used by hash based load balancing methods. + + Minimum value = 1 + + .PARAMETER State + The initial state of the server in the service group. + + .PARAMETER Passthru + Return the service group binding object. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [parameter(Mandatory, ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName = $true)] + [Alias('ServiceGroupName')] + [string[]]$Name, + + [Parameter(Mandatory)] + [string[]]$ServerName, + + [parameter()] + [ValidateScript({$_ -match [IPAddress]$_ })] + [string]$IPAddress, + + [ValidateRange(1, 65535)] + [int]$Port = 80, + + [ValidateRange(1, 100)] + [int]$Weight = 1, + + [int]$ServerId, + + [ValidateRange(1, [int]::MaxValue)] + [int]$HashId, + + [ValidateSet('ENABLED', 'DISABLED')] + [string]$State = 'ENABLED', + + [switch]$PassThru + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $Name) { + foreach ($member in $ServerName) { + if ($PSCmdlet.ShouldProcess($item, "Remove Service Group Member: $Member")) { + try { + $params = @{ + servicegroupname = $item + servername = $member + ip = $IPAddress + port = $Port + weight = $Weight + hashid = $HashId + state = $State + } + _InvokeNSRestApi -Session $Session -Method DELETE -Type servicegroup_servicegroupmember_binding -Payload $params -Action delete + + if ($PSBoundParameters.ContainsKey('PassThru')) { + return Get-NSLBServiceGroupMemberBinding -Session $session -Name $item + } + } catch { + throw $_ + } + } + } + } + } +} + diff --git a/NetScaler/Public/Remove-NSNTPServer.ps1 b/NetScaler/Public/Remove-NSNTPServer.ps1 new file mode 100644 index 0000000..be6cd30 --- /dev/null +++ b/NetScaler/Public/Remove-NSNTPServer.ps1 @@ -0,0 +1,77 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Remove-NSNTPServer { + <# + .SYNOPSIS + Removes an existing NTP server setting. + + .DESCRIPTION + Removes an existing NTP server. + + .EXAMPLE + Remove-NSNTPServer -Server 1.2.3.4 + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER Server + IP address (or array of addresses) of the NTP server(s). + + .PARAMETER Passthru + Return the load balancer server object. + + .NOTES + Nitro implementation status: partial + + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:Session, + + [parameter(Mandatory = $true)] + [String[]]$Server, + + [parameter(Mandatory = $true)] + [String[]]$ServerIP, + + [Switch]$PassThru + ) + + begin { + _AssertSessionActive + } + + process { + $params =@{ + servername = $server + } + foreach ($item in $ServerIP) { + if ($PSCmdlet.ShouldProcess($item, 'Remove NTP server')) { + try { + + _InvokeNSRestApi -Session $Session -Method DELETE -Type ntpserver -Resource $item -Arguments $params -Action delete + + if ($PSBoundParameters.ContainsKey('PassThru')) { + return (Get-NTPServer -Session $session -Name $item) + } + } catch { + throw $_ + } + } + } + } +} diff --git a/NetScaler/Public/Remove-NSResponderPolicy.ps1 b/NetScaler/Public/Remove-NSResponderPolicy.ps1 new file mode 100644 index 0000000..9819bf3 --- /dev/null +++ b/NetScaler/Public/Remove-NSResponderPolicy.ps1 @@ -0,0 +1,64 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Remove-NSResponderPolicy { + <# + .SYNOPSIS + Removes a responder policy. + + .DESCRIPTION + Removes a responder policy. + + .EXAMPLE + Remove-NSResponderPolicy -Name 'act-redirect' + + Removes a responder policy which uses the 'Redirect act' responder action + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER Name + The name of responder policy. + + .PARAMETER Force + Suppress confirmation when removing a responder action. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [parameter(Mandatory, ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName = $true)] + [string[]]$Name, + + [switch]$Force + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $Name) { + if ($Force -or $PSCmdlet.ShouldProcess($item, 'Delete Responder Policy')) { + try { + _InvokeNSRestApi -Session $Session -Method DELETE -Type responderpolicy -Resource $item -Action delete + } catch { + throw $_ + } + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Remove-NSRewriteAction.ps1 b/NetScaler/Public/Remove-NSRewriteAction.ps1 new file mode 100644 index 0000000..d670dfe --- /dev/null +++ b/NetScaler/Public/Remove-NSRewriteAction.ps1 @@ -0,0 +1,69 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Remove-NSRewriteAction { + <# + .SYNOPSIS + Removes a rewrite action. + + .DESCRIPTION + Removes a rewrite action. + + .EXAMPLE + Remove-NSRewriteAction -Name 'act-redirect' + + Removes the rewrite action named 'act-redirect'. + + .EXAMPLE + 'act-1', 'act-2' | Remove-NSRewriteAction + + Removes the rewrite action named 'act-1' and 'act-2'. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER Name + The name or names of the rewrite actions to remove. + + .PARAMETER Force + Suppress confirmation when removing a rewrite action. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='High')] + param( + $Session = $script:session, + + [parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [string[]]$Name, + + [switch]$Force + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $Name) { + if ($Force -or $PSCmdlet.ShouldProcess($item, 'Delete Rewrite Action')) { + try { + _InvokeNSRestApi -Session $Session -Method DELETE -Type rewriteaction -Resource $item -Action delete + } catch { + throw $_ + } + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Remove-NSRewritePolicy.ps1 b/NetScaler/Public/Remove-NSRewritePolicy.ps1 new file mode 100644 index 0000000..d755ac5 --- /dev/null +++ b/NetScaler/Public/Remove-NSRewritePolicy.ps1 @@ -0,0 +1,64 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Remove-NSRewritePolicy { + <# + .SYNOPSIS + Removes a rewrite policy. + + .DESCRIPTION + Removes a rewrite policy. + + .EXAMPLE + Remove-NSRewritePolicy -Name 'act-redirect' + + Removes a rewrite policy which uses the 'Redirect act' rewrite action + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER Name + The name of rewrite policy. + + .PARAMETER Force + Suppress confirmation when removing a rewrite action. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [parameter(Mandatory, ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName = $true)] + [string[]]$Name, + + [switch]$Force + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $Name) { + if ($Force -or $PSCmdlet.ShouldProcess($item, 'Delete Rewrite Policy')) { + try { + _InvokeNSRestApi -Session $Session -Method DELETE -Type rewritepolicy -Resource $item -Action delete + } catch { + throw $_ + } + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Remove-NSVLAN.ps1 b/NetScaler/Public/Remove-NSVLAN.ps1 new file mode 100644 index 0000000..0ae9378 --- /dev/null +++ b/NetScaler/Public/Remove-NSVLAN.ps1 @@ -0,0 +1,61 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Remove-NSVLAN { + <# + .SYNOPSIS + Deletes an untagged/unbound VLAN from NetScaler appliance. + + .DESCRIPTION + Deletes an untagged/unbound VLAN from NetScaler appliance. + + .EXAMPLE + Remove-NSVLAN -VLANID 150 + + Deletes VLAN 150 from the NetScaler appliance. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VLANID + A positive integer that uniquely identifies a VLAN. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')] + param ( + $Session = $script:session, + + [parameter(Mandatory, ValueFromPipeline)] + [string[]]$VLANID + + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $VLANID) { + if ($PSCmdlet.ShouldProcess($item, 'Get VLAN information')) { + try { + _InvokeNSRestApi -Session $Session -Method DELETE -Type vlan -Resource $item -Action delete + } + catch { + throw $_ + } + } + } + } +} diff --git a/NetScaler/Public/Remove-NSVLANInterfaceBinding.ps1 b/NetScaler/Public/Remove-NSVLANInterfaceBinding.ps1 new file mode 100644 index 0000000..67c6e74 --- /dev/null +++ b/NetScaler/Public/Remove-NSVLANInterfaceBinding.ps1 @@ -0,0 +1,80 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Remove-NSVLANInterfaceBinding { + <# + .SYNOPSIS + Deletes the binding of an interface as well as untagged/unbound from NetScaler appliance. + + .DESCRIPTION + Deletes the binding of an interface as well as untagged/unbound from NetScaler appliance. + + .EXAMPLE + Remove-NSVLANBinding -VLANID 150 -AliasName 'testvlan' -MTU 1500 + + Adds VLAN 150 with an alias name of 'testvlan' and MTU of 1500 to the NetScaler appliance. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VLANID + A positive integer that uniquely identifies a VLAN. + + .PARAMETER Interface + The interface to be bound to the VLAN, specified in slot/port notation (for example, 1/3). + + .PARAMETER Tagged + Make the interface an 802.1q tagged interface. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')] + param ( + $Session = $script:session, + + [parameter(Mandatory, ValueFromPipeline)] + [string[]]$VLANID, + + [parameter()] + [string[]]$Interface, + + # [parameter()] + # [switch]$Tagged, + + [Switch]$Force + + ) + + begin { + _AssertSessionActive + } + + process { + + $params = @{ + ifnum = $Interface + #tagged = $Tagged.ToBool() not working - + } + foreach ($item in $VLANID) { + if ($Force -or $PSCmdlet.ShouldProcess($item, 'Remove VLAN binding')) { + try { + _InvokeNSRestApi -Session $Session -Method DELETE -Type vlan_interface_binding -Resource $item -Arguments $params -Action delete + } + catch { + throw $_ + } + } + } + } +} diff --git a/NetScaler/Public/Set-NSCertKeyPair.ps1 b/NetScaler/Public/Set-NSCertKeyPair.ps1 new file mode 100644 index 0000000..0505e9c --- /dev/null +++ b/NetScaler/Public/Set-NSCertKeyPair.ps1 @@ -0,0 +1,122 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Set-NSCertKeyPair { + <# + .SYNOPSIS + Changes server certificate to NetScaler appliance. + + .DESCRIPTION + Changes server certificate to NetScaler appliance. + + .EXAMPLE + Set-NSCertKeyPair -CertKeyName 'myrootCA' -CertPath '/nsconfig/ssl/mycertificate.cert' -CertKeyFormat 'PEM' + + Updates a root certificate key pair named 'myrootCA' using the PEM formatted certificate 'mycertificate.cert' located on the appliance. + + .EXAMPLE + Set-NSCertKeyPair -CertKeyName 'mywildcardcert' -CertPath '/nsconfig/ssl/mywildcard.cert' -KeyPath '/nsconfig/ssl/mywildcard.key' -CertKeyFormat 'PEM' + + Updates a certificate key pair named 'mywildardcert' using the PEM formatted certificate 'mywildcard.cert' and 'mywildcard.key' key file located on the appliance. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER CertKeyName + Name for the certificate and private-key pair. Must begin with an ASCII alphanumeric or underscore (_) character, + and must contain only ASCII alphanumeric, underscore, hash (#), period (.), space, colon (:), at (@), equals (=), + and hyphen (-) characters. Cannot be changed after the certificate-key pair is created. The following requirement + applies only to the NetScaler CLI: If the name includes one or more spaces, enclose the name in double or single + quotation marks (for example, "my cert" or 'my cert'). + + .PARAMETER CertPath + Name of and, optionally, path to the X509 certificate file that is used to form the certificate-key pair. + The certificate file should be present on the appliance's hard-disk drive or solid-state drive. + Storing a certificate in any location other than the default might cause inconsistency in a high availability setup. + '/nsconfig/ssl/' is the default path. + + .PARAMETER KeyPath + Name of and, optionally, path to the private-key file that is used to form the certificate-key pair. + The certificate file should be present on the appliance's hard-disk drive or solid-state drive. + Storing a certificate in any location other than the default might cause inconsistency in a high availability setup. + '/nsconfig/ssl/' is the default path. + + .PARAMETER CertKeyFormat + Input format of the certificate and the private-key files. + The three formats supported by the appliance are: + PEM - Privacy Enhanced Mail + DER - Distinguished Encoding Rule + PFX - PKCS#12 binary format + + Default value: PEM + Possible values = DER, PEM, PFX + + .PARAMETER Password + Passphrase that was used to encrypt the private-key. Use this option to load encrypted private-keys in PEM format. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [Parameter()] + [string]$CertKeyName, + + [Parameter()] + [string]$CertPath, + + [Parameter()] + [string]$KeyPath, + + [Parameter()] + [ValidateSet('PEM','DER','PFX')] + [string]$CertKeyFormat = 'PEM', + + [Parameter()] + [ValidateSet('True','False')] + $NoDomainCheck = $True, + + [Parameter()] + [securestring]$Password + ) + + begin { + _AssertSessionActive + } + + process { + if ($PSCmdlet.ShouldProcess($CertKeyName, 'Update SSL certificate and private key pair')) { + try { + $params = @{ + certkey = $CertKeyName + cert = $CertPath + inform = $CertKeyFormat + nodomaincheck = $NoDomainCheck + } + if ($PSBoundParameters.ContainsKey('KeyPath')) { + $params.Add('key', $KeyPath) + } + if (($CertKeyFormat -in 'PEM','PFX') -and $Password) { + $creds = [System.Management.Automation.PSCredential]::new("dummy", $Password) + $unsecurePassword = $creds.GetNetworkCredential().Password + $params.Add("passplain",$unsecurePassword) + } + $response = _InvokeNSRestApi -Session $Session -Method POST -Type sslcertkey -Payload $params -Action update + } catch { + throw $_ + } + } + } +} diff --git a/NetScaler/Public/Set-NSIPResource.ps1 b/NetScaler/Public/Set-NSIPResource.ps1 new file mode 100644 index 0000000..7e0f50b --- /dev/null +++ b/NetScaler/Public/Set-NSIPResource.ps1 @@ -0,0 +1,163 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Set-NSIPResource { + <# + .SYNOPSIS + Updates an IP resource to the NetScaler appliance. + + .DESCRIPTION + Updates an IP resource to the NetScaler appliance. + + .EXAMPLE + Set-NSIPResource -IPAddress '10.10.10.10' -SubNetMask '255.255.255.0' + + Updates IP address 10.10.10.10 to NetScaler. + + .EXAMPLE + Set-NSIPResource -IPAddress 192.168.30.31 -SubnetMask 255.255.255.0 -Type SNIP -VServer -Telnet -FTP -SNMP -SSH -GUI + + Updates settings for IP address 192.168.30.31 to NetScaler and disabled VServer,SSH, GUI and SNMP but enable but enable Telnet and FTP to Netscaler + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER IPAddress + IPv4 address to create on the NetScaler appliance. + + Note: Cannot be changed after the IP address is created + + .PARAMETER SubnetMask + Subnet mask associated with the IP address. + + .PARAMETER Type + Type of the IP address to create on the NetScaler appliance. Cannot be changed after the IP address is created. + + The following are the different types of NetScaler owned IP addresses: + + * A Subnet IP (SNIP) address is used by the NetScaler ADC to communicate with the servers. + The NetScaler also uses the subnet IP address when generating its own packets, such as packets related to dynamic routing + protocols, or to send monitor probes to check the health of the servers. + + * A Virtual IP (VIP) address is the IP address associated with a virtual server. It is the IP address to which clients connect. + An appliance managing a wide range of traffic may have many VIPs configured. Some of the attributes of the VIP address are + customized to meet the requirements of the virtual server. + + * A GSLB site IP (GSLBIP) address is associated with a GSLB site. It is not mandatory to specify a GSLBIP address when you + initially configure the NetScaler appliance. A GSLBIP address is used only when you create a GSLB site. + + * A Cluster IP (CLIP) address is the management address of the cluster. All cluster configurations must be performed by + accessing the cluster through this IP address. + + Default value: SNIP + Possible values = SNIP, VIP, NSIP, GSLBsiteIP, CLIP + + .PARAMETER VServer + Use this option to set (enable or disable) the virtual server attribute for this IP address. + + Default value: ENABLED + Possible values = ENABLED, DISABLED + + .PARAMETER Telnet + Use this option to set (enable or disable) the virtual server attribute for this IP address. + + Default value: DISABLED + Possible values = ENABLED, DISABLED + + .PARAMETER FTP + Use this option to set (enable or disable) the virtual server attribute for this IP address. + + Default value: DISABLED + Possible values = ENABLED, DISABLED + + .PARAMETER GUI + Use this option to set (enable or disable) the virtual server attribute for this IP address. + + Default value: ENABLED + Possible values = ENABLED, DISABLED + + .PARAMETER SSH + Use this option to set (enable or disable) the virtual server attribute for this IP address. + + Default value: ENABLED + Possible values = ENABLED, DISABLED + + .PARAMETER SNMP + Use this option to set (enable or disable) the virtual server attribute for this IP address. + + Default value: ENABLED + Possible values = ENABLED, DISABLED + + .PARAMETER MgmtAccess + Allow access to management applications on this IP address. + + Default value: DISABLED + Possible values = ENABLED, DISABLED + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [parameter(Mandatory)] + [ValidateScript({$_ -match [IPAddress]$_ })] + [string[]]$IPAddress = (Read-Host -Prompt 'IP resource'), + + [parameter(Mandatory)] + [ValidateScript({$_ -match [IPAddress]$_ })] + [string]$SubnetMask = (Read-Host -Prompt 'Subnet mask'), + + [switch]$VServer, + + [switch]$Telnet, + + [switch]$FTP, + + [switch]$GUI, + + [switch]$SSH, + + [switch]$SNMP, + + [switch]$MgmtAccess + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $IPAddress) { + if ($PSCmdlet.ShouldProcess($item, 'Add IP resource')) { + try { + $params = @{ + ipaddress = $ipaddress + netmask = $SubnetMask + vserver = if ($PSBoundParameters.ContainsKey('VServer')) { 'ENABLED' } else { 'DISABLED' } + telnet = if ($PSBoundParameters.ContainsKey('Telnet')) { 'DISABLED' } else { 'DISABLED' } + ftp = if ($PSBoundParameters.ContainsKey('FTP')) { 'DISABLED' } else { 'DISABLED' } + gui = if ($PSBoundParameters.ContainsKey('GUI')) { 'DISABLED' } else { 'ENABLED' } + ssh = if ($PSBoundParameters.ContainsKey('SSH')) { 'DISABLED' } else { 'ENABLED' } + snmp = if ($PSBoundParameters.ContainsKey('SNMP')) { 'DISABLED' } else { 'ENABLED' } + mgmtaccess = if ($PSBoundParameters.ContainsKey('MgmtAccess')) { 'ENABLED' } else { 'DISABLED' } + } + $response = _InvokeNSRestApi -Session $Session -Method PUT -Type nsip -Payload $params -Action update + } catch { + throw $_ + } + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Set-NSLBMonitor.ps1 b/NetScaler/Public/Set-NSLBMonitor.ps1 new file mode 100644 index 0000000..34a05ff --- /dev/null +++ b/NetScaler/Public/Set-NSLBMonitor.ps1 @@ -0,0 +1,457 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Set-NSLBMonitor { + <# + .SYNOPSIS + Modifies a load balancer server monitor. + + .DESCRIPTION + Modifies a load balancer server monitor. + + .EXAMPLE + Set-NSLBMonitor -Name 'mysite_mon' -Interval 3 -IntervalType MIN -DestinationIP 10.11.12.13 -DestinationPort 80 + + Modifies an existing load balancing monitor with IP address 10.11.12.13 using port 80 every 3 minutes. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER Name + Name for the monitor. + Must begin with an ASCII alphanumeric or underscore (_) character, and must contain + only ASCII alphanumeric, underscore, hash (#), period (.), space, colon (:), at (@), + equals (=), and hyphen (-) characters. + + Minimum length = 1 + + .PARAMETER Type + Type of monitor that you want to create. + + Possible values = PING, TCP, HTTP, TCP-ECV, HTTP-ECV, UDP-ECV, DNS, FTP, LDNS-PING, + LDNS-TCP, LDNS-DNS, RADIUS, USER, HTTP-INLINE, SIP-UDP, LOAD, FTP-EXTENDED, SMTP, + SNMP, NNTP, MYSQL, MYSQL-ECV, MSSQL-ECV, ORACLE-ECV, LDAP, POP3, CITRIX-XML-SERVICE, + CITRIX-WEB-INTERFACE, DNS-TCP, RTSP, ARP, CITRIX-AG, CITRIX-AAC-LOGINPAGE, CITRIX-AAC-LAS, + CITRIX-XD-DDC, ND6, CITRIX-WI-EXTENDED, DIAMETER, RADIUS_ACCOUNTING, STOREFRONT, APPC, + CITRIX-XNC-ECV, CITRIX-XDM + + .PARAMETER Interval + Time interval between two successive probes. Must be greater than the value of Response Time-out. + + Default value: 5 + Minimum value = 1 + Maximum value = 20940000 + + .PARAMETER IntervalType + Monitor interval units. + + Default value: SEC + Possible values = SEC, MSEC, MIN + + .PARAMETER DestinationIP + IP address of the service to which to send probes. + If the parameter is set to 0, the IP address of the server to which the monitor is bound is + considered the destination IP address. + + .PARAMETER DestinationPort + TCP or UDP port to which to send the probe. + If the parameter is set to 0, the port number of the service to which the monitor is bound is + considered the destination port. For a monitor of type USER, however, the destination port is + the port number that is included in the HTTP request sent to the dispatcher. Does not apply to + monitors of type PING. + + .PARAMETER ResponseTimeout + Amount of time for which the appliance must wait before it marks a probe as FAILED. + + .PARAMETER ResponseTimeoutType + Amount of time for which the appliance must wait before it marks a probe as FAILED. + Must be less than the value specified for the Interval parameter. + + Note: For UDP-ECV monitors for which a receive string is not configured, response timeout + does not apply. For UDP-ECV monitors with no receive string, probe failure is indicated by + an ICMP port unreachable error received from the service. + + Default value: 2 + Minimum value = 1 + Maximum value = 20939000 + + .PARAMETER Downtime + Time duration for which to wait before probing a service that has been marked as DOWN. + + .PARAMETER DowntimeType + Time duration for which to wait before probing a service that has been marked as DOWN. + Expressed in milliseconds, seconds, or minutes. + + Default value: 30 + Minimum value = 1 + Maximum value = 20939000 + + .PARAMETER Deviation + Time value added to the learned average response time in dynamic response time monitoring (DRTM). + When a deviation is specified, the appliance learns the average response time of bound services + and adds the deviation to the average. The final value is then continually adjusted to accommodate + response time variations over time. Specified in milliseconds, seconds, or minutes. + + Minimum value = 0 + Maximum value = 20939000 + + .PARAMETER Retries + Maximum number of probes to send to establish the state of a service for which a monitoring probe failed. + + Default value: 3 + Minimum value = 1 + Maximum value = 127 + + .PARAMETER ResponseTimeoutThreshold + Response time threshold, specified as a percentage of the Response Time-out parameter. + If the response to a monitor probe has not arrived when the threshold is reached, the appliance generates + an SNMP trap called monRespTimeoutAboveThresh. After the response time returns to a value below the threshold, + the appliance generates a monRespTimeoutBelowThresh SNMP trap. For the traps to be generated, + the "MONITOR-RTO-THRESHOLD" alarm must also be enabled. + + Minimum value = 0 + Maximum value = 100 + + .PARAMETER AlertRetries + Number of consecutive probe failures after which the appliance generates an SNMP trap called monProbeFailed. + + Minimum value = 0 + Maximum value = 32 + + .PARAMETER SuccessRetries + Number of consecutive successful probes required to transition a service's state from DOWN to UP. + + Default value: 1 + Minimum value = 1 + Maximum value = 32 + + .PARAMETER FailureRetries + Number of retries that must fail, out of the number specified for the Retries parameter, for a service to be marked as DOWN. + For example, if the Retries parameter is set to 10 and the Failure Retries parameter is set to 6, out of the ten probes + sent, at least six probes must fail if the service is to be marked as DOWN. The default value of 0 means that all the retries + must fail if the service is to be marked as DOWN. + + Minimum value = 0 + Maximum value = 32 + + .PARAMETER NetProfile + Name of the network profile. + + Minimum length = 1 + Maximum length = 127 + + .PARAMETER TOS + Probe the service by encoding the destination IP address in the IP TOS (6) bits. + + Possible values = YES, NO + + .PARAMETER TOSID + The TOS ID of the specified destination IP. + Applicable only when the TOS parameter is set. + + Minimum value = 1 + Maximum value = 63 + + .PARAMETER State + State of the monitor. + The DISABLED setting disables not only the monitor being configured, but all monitors of the same type, until the parameter + is set to ENABLED. If the monitor is bound to a service, the state of the monitor is not taken into account when the state + of the service is determined. + + Default value: ENABLED + Possible values = ENABLED, DISABLED + + .PARAMETER Reverse + Mark a service as DOWN, instead of UP, when probe criteria are satisfied, and as UP instead of DOWN when probe criteria are + not satisfied. + + Default value: NO + Possible values = YES, NO + + .PARAMETER Transparent + The monitor is bound to a transparent device such as a firewall or router. + The state of a transparent device depends on the responsiveness of the services behind it. If a transparent device is being + monitored, a destination IP address must be specified. The probe is sent to the specified IP address by using the MAC address + of the transparent device. + + Default value: NO + Possible values = YES, NO + + .PARAMETER LRTM + Calculate the least response times for bound services. + If this parameter is not enabled, the appliance does not learn the response times of the bound services. Also used for LRTM + load balancing. + + Possible values = ENABLED, DISABLED + + .PARAMETER Secure + Use a secure SSL connection when monitoring a service. + Applicable only to TCP based monitors. The secure option cannot be used with a CITRIX-AG monitor, because a CITRIX-AG monitor + uses a secure connection by default. + + Default value: NO + Possible values = YES, NO + + .PARAMETER IPTunnel + Send the monitoring probe to the service through an IP tunnel. A destination IP address must be specified. + + Default value: NO + Possible values = YES, NO + + .PARAMETER ScriptName + Path and name of the script to execute. + The script must be available on the NetScaler appliance, in the /nsconfig/monitors/ directory. + + Minimum length = 1 + + .PARAMETER DispatcherIP + IP address of the dispatcher to which to send the probe. + + .PARAMETER DispatcherPort + IP address of the dispatcher to which to send the probe. + + .PARAMETER ScriptArgs + String of arguments for the script. The string is copied verbatim into the request. + + .PARAMETER CustomProperty + Send additional monitor-specific properties when creating the monitor. + + Example STOREFRONT monitor value: @{ StoreName = 'Store' } + + .PARAMETER ResponseCode + Response codes for which to mark the service as UP + + .PARAMETER HTTPRequest + HTTP request to send to the server (for example, "HEAD /file.html"). + + .PARAMETER Passthru + Return the load balancer monitor object. + + .PARAMETER Send + String to send to the service. Applicable to TCP-ECV, HTTP-ECV, and UDP-ECV monitors. + + .PARAMETER Recv + String expected from the server for the service to be marked as UP. Applicable to TCP-ECV, HTTP-ECV, and UDP-ECV monitors. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [parameter(Mandatory = $true)] + [string[]]$Name = (Read-Host -Prompt 'Monitor name'), + + [ValidateSet('PING', 'TCP', 'HTTP', 'TCP-ECV', 'HTTP-ECV', 'UDP-ECV', 'DNS', 'FTP', 'LDNS-PING', + 'LDNS-TCP', 'RADIUS', 'USER', 'HTTP-INLINE', 'SIP-UDP', 'LOAD', 'FTP-EXTENDED', 'SMTP', 'SNMP', + 'NNTP', 'MYSQL', 'MYSQL-ECV', 'MSSQL-ECV', 'ORACLE-ECV', 'LDAP', 'POP3', 'CITRIX-XML-SERVICE', + 'CITRIX-WEB-INTERFACE', 'DNS-TCP', 'RTSP', 'ARP', 'CITRIX-AG', 'CITRIX-AAC-LOGINPAGE', 'CITRIX-AAC-LAS', + 'CITRIX-XD-DDC', 'ND6', 'CITRIX-WI-EXTENDED', 'DIAMETER', 'RADIUS_ACCOUNTING', 'STOREFRONT')] + [string]$Type = 'PING', + + [ValidateRange(1, 20940000)] + [int]$Interval = 5, + + [ValidateSet('SEC', 'MSEC', 'MIN')] + [string]$IntervalType = 'SEC', + + [ValidateScript({$_ -match [IPAddress]$_ })] + [string]$DestinationIP, + + [int]$DestinationPort, + + [ValidateRange(1, 20939000)] + [int]$ResponseTimeout = 2, + + [ValidateSet('SEC', 'MSEC', 'MIN')] + [string]$ResponseTimeoutType = 'SEC', + + [ValidateRange(1, 20939000)] + [int]$Downtime = 30, + + [ValidateSet('SEC', 'MSEC', 'MIN')] + [string]$DowntimeType = 'SEC', + + [ValidateRange(0, 20939000)] + [int]$Deviation, + + [ValidateRange(1, 127)] + [int]$Retries = 3, + + [ValidateRange(0, 100)] + [int]$ResponseTimeoutThreshold, + + [ValidateRange(0, 32)] + [int]$AlertRetries, + + [ValidateRange(0, 32)] + [int]$SuccessRetries = 1, + + [ValidateRange(0, 32)] + [int]$FailureRetries, + + [ValidateRange(1, 127)] + [string]$NetProfile, + + [ValidateSet('YES', 'NO')] + [string]$TOS = 'NO', + + [ValidateRange(1, 63)] + [int]$TOSID, + + [ValidateSet('ENABLED', 'DISABLED')] + [string]$State = 'ENABLED', + + [ValidateSet('Yes', 'NO')] + [string]$Reverse = 'NO', + + [ValidateSet('YES', 'NO')] + [string]$Transparent = 'NO', + + [ValidateSet('ENABLED', 'DISABLED')] + [string]$LRTM = 'DISABLED', + + [ValidateSet('YES', 'NO')] + [string]$Secure = 'NO', + + [ValidateSet('YES', 'NO')] + [string]$IPTunnel = 'NO', + + [string]$ScriptName, + + [ValidateScript({$_ -match [IPAddress]$_ })] + [string]$DispatcherIP, + + [int]$DispatcherPort, + + [string]$ScriptArgs, + + [System.Collections.Hashtable]$CustomProperty, + + [switch]$PassThru, + + [Parameter()] + [string[]] + $ResponseCode, + + [Parameter()] + [string] + $HTTPRequest, + + [Parameter()] + [string] + $Send, + + [Parameter()] + [string] + $Recv + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $Name) { + if ($PSCmdlet.ShouldProcess($item, 'Update Monitor')) { + try { + $existingMonitor = Get-NSLBMonitor -Name $item + $params = @{ + monitorname = $item + type = $existingMonitor.type + interval = $Interval + units3 = $IntervalType + units4 = $ResponseTimeoutType + downtime = $Downtime + units2 = $DowntimeType + retries = $Retries + resptimeout = $ResponseTimeout + successretries = $SuccessRetries + tos = $TOS + state = $State + reverse = $Reverse + transparent = $Transparent + lrtm = $LRTM + secure = $Secure + iptunnel = $IPTunnel + } + if ($PSBoundParameters.ContainsKey('DestinationIP')) { + $params.Add('destip', $DestinationIP) + } + if ($PSBoundParameters.ContainsKey('DestinationPort')) { + $params.Add('destport', $DestinationPort) + } + if ($PSBoundParameters.ContainsKey('Deviation')) { + $params.Add('deviation', $Deviation) + } + if ($PSBoundParameters.ContainsKey('ResponseTimeoutThreshold')) { + $params.Add('resptimeoutthresh', $ResponseTimeoutThreshold) + } + if ($PSBoundParameters.ContainsKey('AlertRetries')) { + $params.Add('alertretries', $AlertRetries) + } + if ($PSBoundParameters.ContainsKey('FailureRetries')) { + $params.Add('failureretries', $FailureRetries) + } + if ($PSBoundParameters.ContainsKey('NetProfile')) { + $params.Add('netprofile', $NetProfile) + } + if ($PSBoundParameters.ContainsKey('TOSID')) { + $params.Add('tosid', $TOSID) + } + if ($PSBoundParameters.ContainsKey('ScriptName')) { + $params.Add('scriptname', $ScriptName) + } + if ($PSBoundParameters.ContainsKey('DispatcherIP')) { + $params.Add('dispatcherip', $DispatcherIP) + } + if ($PSBoundParameters.ContainsKey('ScriptArgs')) { + $params.Add('scriptargs', $ScriptArgs) + } + if ($PSBoundParameters.ContainsKey('CustomProperty')) { + ## Add each custom property to the $params Hashtable + foreach ($key in $CustomProperty.Keys) { + $params.Add($key.ToLower(), $CustomProperty[$key]) + } + } + if ($PSBoundParameters.ContainsKey('ResponseCode')) { + ## Add each custom property to the $params Hashtable + foreach ($rc in $ResponseCode.Keys) { + $params.Add($rc.ToLower(), $ResponseCode[$rc]) + } + } + # if ($PSBoundParameters.ContainsKey('ResponseCode')) { + # $params.Add('respcode', $ResponseCode) + # } + if ($PSBoundParameters.ContainsKey('HTTPRequest')) { + $params.Add('httprequest', $HTTPRequest) + } + if ($PSBoundParameters.ContainsKey('Send')) { + $params.Add('send', $Send) + } + if ($PSBoundParameters.ContainsKey('Recv')) { + $params.Add('recv', $Recv) + } + _InvokeNSRestApi -Session $Session -Method PUT -Type lbmonitor -Payload $params + + if ($PSBoundParameters.ContainsKey('PassThru')) { + return Get-NSLBMonitor -Session $session -Name $item + } + } catch { + throw $_ + } + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Set-NSLBServiceGroup.ps1 b/NetScaler/Public/Set-NSLBServiceGroup.ps1 index 33db106..d943990 100644 --- a/NetScaler/Public/Set-NSLBServiceGroup.ps1 +++ b/NetScaler/Public/Set-NSLBServiceGroup.ps1 @@ -25,7 +25,7 @@ function Set-NSLBServiceGroup { .EXAMPLE Set-NSLBServiceGroup -Name 'sg01' -Comment 'This is a comment' - Sets the comment for virtual server 'sg01'. + Updates the comment for virtual server 'sg01'. .EXAMPLE Set-NSLBServiceGroup -Name 'sg01' HTTPCompression = 'ON' @@ -33,7 +33,7 @@ function Set-NSLBServiceGroup { Enable the HTTP compression feature for service group 'sg01'. .EXAMPLE - Set-NSLBServiceGroup -Name 'sg01' MaxBandwithKbps 819200 + Set-NSLBServiceGroup -Name 'sg01' MaxBandwidthKbps 819200 Set the maximum bandwidth for service group 'sg01' to 819200 Kbps. @@ -43,6 +43,16 @@ function Set-NSLBServiceGroup { .PARAMETER Name The name or names of the service groups to update. + .PARAMETER State + Initial state of the service group. + Default value: ENABLED + Possible values = ENABLED, DISABLED + + .PARAMETER AutoScale + Auto scale option for a servicegroup. + Default value: DISABLED + Possible values = DISABLED, DNS, POLICY + .PARAMETER Cacheable Use the transparent cache redirection virtual server to forward the request to the cache server. @@ -79,10 +89,7 @@ function Set-NSLBServiceGroup { .PARAMETER ClientIP Insert the Client IP header in requests forwarded to the service. - .PARAMETER ClientIPHeader - Name of the HTTP header whose value must be set to the IP address of the client. - - .PARAMETER MaxBandwithKbps + .PARAMETER MaxBandwidthKbps Maximum bandwidth, in Kbps, allocated for all the services in the service group. .PARAMETER MonitorThreshold @@ -110,20 +117,29 @@ function Set-NSLBServiceGroup { param( $Session = $script:session, - [parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName)] - [Alias('ServiceGroupName')] + [parameter(Mandatory, ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName = $true)] [string[]]$Name = (Read-Host -Prompt 'LB service group name'), + [ValidateSet('SERVER', 'FORWARD', 'TRANSPARENT', 'REVERSE')] + [string]$CacheType, + + [ValidateSet('DISABLED', 'DNS', 'POLICY')] + [string]$AutoScale = 'DISABLED', + [ValidateSet('NO', 'YES')] [string]$Cacheable = 'NO', + [ValidateSet('ENABLED', 'DISABLED')] + [string]$State = 'ENABLED', + [ValidateSet('NO', 'YES')] [string]$HealthMonitor = 'YES', [ValidateSet('DISABLED', 'ENABLED')] [string]$AppFlowLog = 'ENABLED', - [string]$Comment, + [ValidateLength(0, 256)] + [string]$Comment = [string]::Empty, [ValidateSet('ON', 'OFF')] [string]$SureConnect = 'OFF', @@ -140,6 +156,9 @@ function Set-NSLBServiceGroup { [ValidateSet('YES','NO')] [string]$UseClientIP = 'NO', + [ValidateSet('YES','NO')] + [string]$ClientKeepAlive = 'NO', + [ValidateSet('YES', 'NO')] [string]$TCPBuffering = 'NO', @@ -149,10 +168,8 @@ function Set-NSLBServiceGroup { [ValidateSet('ENABLED','DISABLED')] [string]$ClientIP = 'DISABLED', - [string]$ClientIPHeader, - [ValidateRange(0, 4294967287)] - [int]$MaxBandwithKbps, + [int]$MaxBandwidthKbps, [ValidateRange(0, 65535)] [int]$MonitorThreshold, @@ -169,7 +186,7 @@ function Set-NSLBServiceGroup { [ValidateRange(0, 31536000)] [int]$ServerIdleTimeout = 360, - [Switch]$Force, + [Switch]$Force, [Switch]$PassThru ) @@ -183,10 +200,17 @@ function Set-NSLBServiceGroup { if ($Force -or $PSCmdlet.ShouldProcess($item, 'Edit Service Group')) { $params = @{ servicegroupname = $item - } + state = $State + } + if ($PSBoundParameters.ContainsKey('CacheType')) { + $params.Add('cachetype', $CacheType) + } if ($PSBoundParameters.ContainsKey('Cacheable')) { $params.Add('cacheable', $Cacheable) } + if ($PSBoundParameters.ContainsKey('AutoScale')) { + $params.Add('autoScale', $AutoScale) + } if ($PSBoundParameters.ContainsKey('HealthMonitor')) { $params.Add('healthmonitor', $HealthMonitor) } @@ -211,6 +235,9 @@ function Set-NSLBServiceGroup { if ($PSBoundParameters.ContainsKey('UseClientIP')) { $params.Add('usip', $UseClientIP) } + if ($PSBoundParameters.ContainsKey('ClientKeepAlive')) { + $params.Add('cka', $ClientKeepAlive) + } if ($PSBoundParameters.ContainsKey('TCPBuffering')) { $params.Add('tcpb', $TCPBuffering) } @@ -220,11 +247,8 @@ function Set-NSLBServiceGroup { if ($PSBoundParameters.ContainsKey('ClientIP')) { $params.Add('cip', $ClientIP) } - if ($ClientIP -eq 'ENABLED') { - $params.Add('cipheader', $ClientIPHeader) - } - if ($PSBoundParameters.ContainsKey('MaxBandwithKbps')) { - $params.Add('maxbandwitch', $MaxBandwithKbps) + if ($PSBoundParameters.ContainsKey('MaxBandwidthKbps')) { + $params.Add('maxbandwidth', $MaxBandwidthKbps) } if ($PSBoundParameters.ContainsKey('MonitorThreshold')) { $params.Add('monthreshold', $MonitorThreshold) diff --git a/NetScaler/Public/Set-NSLBVirtualServer.ps1 b/NetScaler/Public/Set-NSLBVirtualServer.ps1 index 8ccd98a..88ab0f7 100644 --- a/NetScaler/Public/Set-NSLBVirtualServer.ps1 +++ b/NetScaler/Public/Set-NSLBVirtualServer.ps1 @@ -33,9 +33,9 @@ function Set-NSLBVirtualServer { Sets the comment for virtual server 'vserver01' and returns the updated object. .EXAMPLE - Set-NSLBVirtualServer -Name 'vserver01' -IPAddress '11.11.11.11' -Force + Set-NSLBVirtualServer -Name 'vserver01' -IPAddress '11.11.11.11' -HttpRedirectURL "http://google.com" -Force - Sets the IP address for virtual server 'vserver01' to '11.11.11.11' and suppresses confirmation. + Sets the IP address for virtual server 'vserver01' to '11.11.11.11' with a redirect to Google.com in case the backend services/service group are not available and suppresses confirmation. .PARAMETER Session The NetScaler session object. @@ -43,6 +43,9 @@ function Set-NSLBVirtualServer { .PARAMETER Name The name or names of the load balancer virtual servers to set. + .PARAMETER PersistenceType + The type of persistence for the virtual server. Possible values = SOURCEIP, COOKIEINSERT, SSLSESSION, RULE, URLPASSIVE, CUSTOMSERVERID, DESTIP, SRCIPDESTIP, CALLID, RTSPSID, DIAMETER, NONE + .PARAMETER LBMethod The load balancing method of the virtual server. @@ -52,6 +55,15 @@ function Set-NSLBVirtualServer { .PARAMETER Comment The comment associated with the virtual server. + .PARAMETER HttpRedirectURL + The URL to which to redirect traffic if the virtual server becomes unavailable. + + .PARAMETER ICMPVSRResponse + The URL to which to redirect traffic if the virtual server becomes unavailable. The dfault value is "Passive" + + .PARAMETER TimeOut + The time period for which a persistence session is in effect. The default value is 2 seconds. + .PARAMETER Force Suppress confirmation when updating a virtual server. @@ -68,12 +80,29 @@ function Set-NSLBVirtualServer { [ValidateSet('ROUNDROBIN', 'LEASTCONNECTION', 'LEASTRESPONSETIME', 'LEASTBANDWIDTH', 'LEASTPACKETS', 'CUSTOMLOAD', 'LRTM', 'URLHASH', 'DOMAINHASH', 'DESTINATIONIPHASH', 'SOURCEIPHASH', 'TOKEN', 'SRCIPDESTIPHASH', 'SRCIPSRCPORTHASH', 'CALLIDHASH')] [string]$LBMethod = 'ROUNDROBIN', + [Parameter()] + [ValidateSet('SOURCEIP', 'COOKIEINSERT', 'SSLSESSION', 'CUSTOMSERVERID', 'RULE', 'URLPASSIVE', 'DESTIP', 'SRCIPDESTIP', 'CALLID' ,'RTSPID', 'FIXSESSION', 'NONE')] + [string] + $PersistenceType, + [ValidateScript({$_ -match [IPAddress]$_ })] [string]$IPAddress, + [Parameter()] + [string] + $HttpRedirectURL, + + [Parameter()] [ValidateLength(0, 256)] [string]$Comment = '', + [Parameter()] + [ValidateLength(0, 256)] + [string]$ICMPVSRResponse = 'PASSIVE', + + [Parameter()] + [int]$TimeOut = 2, + [Switch]$Force, [Switch]$PassThru @@ -88,16 +117,24 @@ function Set-NSLBVirtualServer { if ($Force -or $PSCmdlet.ShouldProcess($item, 'Edit Virtual Server')) { $params = @{ name = $item + timeout = $TimeOut + icmpvsrresponse = $ICMPVSRResponse } if ($PSBoundParameters.ContainsKey('LBMethod')) { $params.Add('lbmethod', $LBMethod) } + if ($PSBoundParameters.ContainsKey('PersistenceType')) { + $params.Add('persistencetype', $PersistenceType) + } if ($PSBoundParameters.ContainsKey('Comment')) { $params.Add('comment', $Comment) } if ($PSBoundParameters.ContainsKey('IPAddress')) { $params.Add('ipv46', $IPAddress) } + if ($PSBoundParameters.ContainsKey('HttpRedirectURL')) { + $params.Add('redirurl', $HttpRedirectURL) + } _InvokeNSRestApi -Session $Session -Method PUT -Type lbvserver -Payload $params -Action update diff --git a/NetScaler/Public/Set-NSNTPServer.ps1 b/NetScaler/Public/Set-NSNTPServer.ps1 new file mode 100644 index 0000000..fcf94e2 --- /dev/null +++ b/NetScaler/Public/Set-NSNTPServer.ps1 @@ -0,0 +1,99 @@ +<# +Copyright 2016 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Set-NSNTPServer { + <# + .SYNOPSIS + Updates an existing NTP server setting. + + .DESCRIPTION + Updates an existing NTP server. + + .EXAMPLE + Set-NSNTPServer -Server 1.2.3.4 + + Create a new KCD account with the given delegate user. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER Server + IP address (or array of addresses) of the NTP server(s). + + .PARAMETER MinPollInterval + Minimum poll interval: minimum time after which Netscaler must poll the NTP server. + Expressed power of 2 seconds. + + Default value: 6 (64 seconds) + + .PARAMETER MaxPollInterval + Maximum poll interval: maximum time after which Netscaler must poll the NTP server. + Expressed power of 2 seconds. + + Default value: 10 (1024 seconds) + + .PARAMETER Passthru + Return the load balancer server object. + + .NOTES + Nitro implementation status: partial + + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:Session, + + [parameter(Mandatory = $true)] + [String[]]$Server, + + [Int]$MinPollInterval = 6, + + [Int]$MaxPollInterval = 10, + + [parameter(Mandatory = $true)] + [ValidateSet('Yes','No')] + [string]$preferredntpserver = 'Yes', + + [Switch]$PassThru + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $Server) { + if ($PSCmdlet.ShouldProcess($item, 'Update NTP server')) { + try { + $params = @{ + servername = $item + minpoll = $MinPollInterval + maxpoll = $MaxPollInterval + autokey = 'false' + preferredntpserver = $PreferredNTPServer + } + _InvokeNSRestApi -Session $Session -Method PUT -Type ntpserver -Payload $params -Action update + + if ($PSBoundParameters.ContainsKey('PassThru')) { + return (Get-NTPServer -Session $session -Name $item) + } + } catch { + throw $_ + } + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Set-NSResponderPolicy.ps1 b/NetScaler/Public/Set-NSResponderPolicy.ps1 new file mode 100644 index 0000000..2c6b616 --- /dev/null +++ b/NetScaler/Public/Set-NSResponderPolicy.ps1 @@ -0,0 +1,94 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Set-NSResponderPolicy { + <# + .SYNOPSIS + Updates a responder policy. + + .DESCRIPTION + Updates a responder policy. + + .EXAMPLE + Set-NSResponderPolicy -Name 'act-redirect' -Rule 'HTTP.REQ.URL.EQ("/")' -Action 'Redirect act' + + Updates a responder policy which uses the 'Redirect act' responder action + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER Name + The name of responder policy. + + .PARAMETER Rule + Default syntax expression that the policy uses to determine whether to respond to the specified request. + + .PARAMETER Action + Name of the responder action to perform if the request matches this responder policy. There are also some built-in actions which can be used. These are: + * NOOP - Send the request to the protected server instead of responding to it. + * RESET - Reset the client connection by closing it. The client program, such as a browser, will handle this and may inform the user. The client may then resend the request if desired. + * DROP - Drop the request without sending a response to the user. + + .PARAMETER Passthru + Return the responder policy. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [parameter(Mandatory, ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName = $true)] + [string[]]$Name, + + [Parameter()] + [string] + $Rule, + + [Parameter()] + [string] + $Action, + + [Parameter()] + [string]$Comment, + + [Switch]$PassThru + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($Item in $Name) { + if ($PSCmdlet.ShouldProcess($Item, 'Update Responder Policy')) { + try { + $params = @{ + name = $Item + rule = $Rule + action = $Action + comment = $Comment + } + _InvokeNSRestApi -Session $Session -Method PUT -Type responderpolicy -Payload $params -Action update + + if ($PSBoundParameters.ContainsKey('PassThru')) { + return Get-NSResponderPolicy -Session $session -Name $item + } + } catch { + throw $_ + } + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Set-NSRewriteAction.ps1 b/NetScaler/Public/Set-NSRewriteAction.ps1 new file mode 100644 index 0000000..b79f2a7 --- /dev/null +++ b/NetScaler/Public/Set-NSRewriteAction.ps1 @@ -0,0 +1,114 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Set-NSRewriteAction { + <# + .SYNOPSIS + Updates a rewrite action. + + .DESCRIPTION + Updates a rewrite action. + + .EXAMPLE + Set-NSRewriteAction -Name 'act-rewrite' -Type Replace ` + -Target 'HTTP.REQ.HOSTNAME' -Expression '"www.lab.local"' + + Updates a rewrite action which rewrites the 'Host' header with the value 'www.lab.local' + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER Name + The name of rewrite action. + + .PARAMETER Type + The type of rewrite action to create. + + Possible values = Replace + + .PARAMETER Target + The target expression for the rewrite action. + + Minimum length: 0 + Maximum length: 8191 + + .PARAMETER Expression + The expression value used by the rewrite target. Its exact meaning depends on the type. + + Minimum length: 0 + Maximum length: 8191 + + .PARAMETER Comment + Any information about the rewrite action. + + Minimum length: 0 + Maximum length: 256 + + .PARAMETER Passthru + Return the rewrite action. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [Parameter(Mandatory, ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName = $true)] + [string[]]$Name, + + [Parameter(Mandatory)] + [ValidateSet('Replace')] + [string]$Type, + + [Parameter(Mandatory)] + [ValidateLength(0, 8191)] + [string]$Target, + + [Parameter(Mandatory)] + [ValidateLength(0, 8191)] + [string]$Expression, + + [ValidateLength(0, 256)] + [string]$Comment = [string]::Empty, + + [Switch]$PassThru + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($Item in $Name) { + if ($PSCmdlet.ShouldProcess($Item, 'Create rewrite action')) { + try { + $params = @{ + name = $Item + type = $Type.ToLower() + comment = $Comment + target = $Target + stringbuilderexpr = $Expression + } + _InvokeNSRestApi -Session $Session -Method PUT -Type rewriteaction -Payload $params -Action update + + if ($PSBoundParameters.ContainsKey('PassThru')) { + return Get-NSRewriteAction -Session $Session -Name $Item + } + } catch { + throw $_ + } + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Set-NSRewritePolicy.ps1 b/NetScaler/Public/Set-NSRewritePolicy.ps1 new file mode 100644 index 0000000..eadbd6f --- /dev/null +++ b/NetScaler/Public/Set-NSRewritePolicy.ps1 @@ -0,0 +1,116 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Set-NSRewritePolicy { + <# + .SYNOPSIS + Updates a rewrite porlicy. + + .DESCRIPTION + Updates a rewrite policy. + + .EXAMPLE + Set-NSRewritePolicy -Name 'pol-rewrite' -ActionName 'act-rewrite' -Expression 'true' + + Creates a new rewrite policy which always applies the 'act-rewrite' action. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER Name + The name of rewrite policy. + + .PARAMETER ActionName + The name of the action to execute when this policy is matched. + + .PARAMETER LogActionName + The name of the log action to execute when this policy is matched. + + Default value: "" + + .PARAMETER Rule + The rule/expression that has to be matched for this policy to apply. + + Minimum length: 0 + Maximum length: 8191 + Alias: Expression + + .PARAMETER Expression + The rule/expression that has to be matched for this policy to apply. + + Minimum length: 0 + Maximum length: 8191 + Alias for: Rule + + .PARAMETER Comment + Any information about the rewrite policy. + + Minimum length: 0 + Maximum length: 256 + + .PARAMETER Passthru + Return the rewrite policy. + #> + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [Parameter(Mandatory, ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName = $true)] + [string[]]$Name, + + [Parameter()] + [string]$ActionName, + + [string]$LogActionName = "", + + [Parameter()] + [ValidateLength(0, 8191)] + [Alias('Expression')] + [string]$Rule, + + [ValidateLength(0, 256)] + [string]$Comment = "", + + [Switch]$PassThru + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($Item in $Name) { + if ($PSCmdlet.ShouldProcess($Item, 'Updates rewrite policy')) { + try { + $params = @{ + name = $Item + action = $ActionName + comment = $Comment + logaction = $LogActionName + rule = $Rule + } + _InvokeNSRestApi -Session $Session -Method PUT -Type rewritepolicy -Payload $params -Action update + + if ($PSBoundParameters.ContainsKey('PassThru')) { + return Get-NSRewritePolicy -Session $Session -Name $Item + } + } catch { + throw $_ + } + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Set-NSVLAN.ps1 b/NetScaler/Public/Set-NSVLAN.ps1 new file mode 100644 index 0000000..f8b76e2 --- /dev/null +++ b/NetScaler/Public/Set-NSVLAN.ps1 @@ -0,0 +1,90 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Set-NSVLAN { + <# + .SYNOPSIS + Updates a particular VLAN parameters in the NetScaler appliance. + + .DESCRIPTION + Updates a particular VLAN parameters in the NetScaler appliance. + + .EXAMPLE + Set-NSVLAN -VLANID 150 -AliasName 'vlan150' + + Updates VLAN 150 alias labeled 'vlan150' on the NetScaler appliance. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VLANID + A positive integer that uniquely identifies a VLAN. + + .PARAMETER AliasName + A name for the VLAN. Must begin with a letter, a number, or the underscore symbol, and can consist of from 1 to 31 letters, numbers, and the hyphen (-), period (.) pound (#), space ( ), at sign (@), equals (=), colon (:), and underscore (_) characters. + + .PARAMETER IPV6DynamicRouting + Enable all IPv6 dynamic routing protocols on this VLAN. Note: For the ENABLED setting to work, you must configure IPv6 dynamic routing protocols from the VTYSH command line. Possible values = ENABLED, DISABLED + + .PARAMETER MTU + Specifies the maximum transmission unit (MTU), in bytes. + + .PARAMETER Force + Suppress confirmation when adding a DNS suffix. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')] + param ( + $Session = $script:session, + + [parameter(Mandatory, ValueFromPipeline)] + [int]$VLANID, + + [parameter()] + [string[]]$AliasName, + + [parameter()] + [string[]]$IPV6DynamicRouting = 'Disabled', + + [parameter()] + [int]$MTU, + + [Switch]$Force + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $VLANID) { + if ($PSCmdlet.ShouldProcess($item, 'Add VLAN suffix')) { + try { + $params = @{ + id = $item + aliasname = $AliasName + ipv6dynamicrouting = $IPV6DynamicRouting + mtu = $MTU + + } + $response = _InvokeNSRestApi -Session $Session -Method PUT -Type vlan -Payload $params -Action update + } + catch { + throw $_ + } + } + } + } +} \ No newline at end of file From e15f299919977a0ae508885fa0bd90a6046537b6 Mon Sep 17 00:00:00 2001 From: Herrera Date: Mon, 10 Jul 2017 10:47:10 -0700 Subject: [PATCH 2/7] added and modified additional functions --- NetScaler/NetScaler.psd1 | 2 +- NetScaler/Public/Get-NSResponderHTMLPage.ps1 | 28 +++----------------- NetScaler/Public/New-NSLBServer.ps1 | 6 ++--- NetScaler/Public/New-NSLBService.ps1 | 2 +- NetScaler/Public/Remove-NSDnsNameServer.ps1 | 2 +- 5 files changed, 10 insertions(+), 30 deletions(-) diff --git a/NetScaler/NetScaler.psd1 b/NetScaler/NetScaler.psd1 index 6667045..2590b6e 100644 --- a/NetScaler/NetScaler.psd1 +++ b/NetScaler/NetScaler.psd1 @@ -12,7 +12,7 @@ RootModule = 'NetScaler.psm1' # Version number of this module. -ModuleVersion = '1.5.0' +ModuleVersion = '1.5.1' # ID used to uniquely identify this module GUID = 'bd4390dc-a8ad-4bce-8d69-f53ccf8e4163' diff --git a/NetScaler/Public/Get-NSResponderHTMLPage.ps1 b/NetScaler/Public/Get-NSResponderHTMLPage.ps1 index f9c44ee..a11e563 100644 --- a/NetScaler/Public/Get-NSResponderHTMLPage.ps1 +++ b/NetScaler/Public/Get-NSResponderHTMLPage.ps1 @@ -1,5 +1,5 @@ <# -Copyright 2017 Juan Herrera +Copyright 2017 Juan C. Herrera Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,21 +17,16 @@ limitations under the License. function Get-NSResponderHTMLPage { <# .SYNOPSIS - Add server certificate to NetScaler appliance. + Retrieve a responder HTML page from the NetScaler appliance. .DESCRIPTION - Add server certificate to NetScaler appliance. + Retrieve a responder HTML page from the NetScaler appliance. .EXAMPLE - Add-NSCertKeyPair -CertKeyName 'myrootCA' -CertPath '/nsconfig/ssl/mycertificate.cert' -CertKeyFormat 'PEM' + Get-NSResponderHTMLPage -Name 'myHTMLpage' Creates a root certificate key pair named 'myrootCA' using the PEM formatted certificate 'mycertificate.cert' located on the appliance. - .EXAMPLE - Add-NSCertKeyPair -CertKeyName 'mywildcardcert' -CertPath '/nsconfig/ssl/mywildcard.cert' -KeyPath '/nsconfig/ssl/mywildcard.key' -CertKeyFormat 'PEM' - - Creates a certificate key pair named 'mywildardcert' using the PEM formatted certificate 'mywildcard.cert' and 'mywildcard.key' key file located on the appliance. - .PARAMETER Session The NetScaler session object. @@ -52,21 +47,6 @@ function Get-NSResponderHTMLPage { _AssertSessionActive } -# process { -# if ($PSCmdlet.ShouldProcess($Name, 'Add a HTML Responder page')) { -# try { -# $params = @{ -# name = $Name -# } -# $response = _InvokeNSRestApi -Session $Session -Method GET -Type responderhtmlpage -Payload $params -Action get -# } catch { -# throw $_ -# } -# } -# } -# } - - process { # Contruct a filter hash if we specified any filters # $Filters = @{} diff --git a/NetScaler/Public/New-NSLBServer.ps1 b/NetScaler/Public/New-NSLBServer.ps1 index b1a414c..181aab4 100644 --- a/NetScaler/Public/New-NSLBServer.ps1 +++ b/NetScaler/Public/New-NSLBServer.ps1 @@ -113,11 +113,11 @@ function New-NSLBServer { $params = @{ name = $item comment = $Comment - td = $TrafficDomainId + ipaddress = $IPAddress state = $State } - if ($PSBoundParameters.ContainsKey('IPAddress')) { - $params.Add('ipaddress', $IPAddress) + if ($PSBoundParameters.ContainsKey('TrafficDomainId')) { + $params.Add('td', $TrafficDomainId) } if ($PSBoundParameters.ContainsKey('Domain')) { $params.Add('domain', $Domain) diff --git a/NetScaler/Public/New-NSLBService.ps1 b/NetScaler/Public/New-NSLBService.ps1 index 59e24e8..3ad081c 100644 --- a/NetScaler/Public/New-NSLBService.ps1 +++ b/NetScaler/Public/New-NSLBService.ps1 @@ -1,5 +1,5 @@ <# -Copyright 2017 Juan Herrera +Copyright 2017 Juan C. Herrera Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/NetScaler/Public/Remove-NSDnsNameServer.ps1 b/NetScaler/Public/Remove-NSDnsNameServer.ps1 index 87a5a30..522a8d3 100644 --- a/NetScaler/Public/Remove-NSDnsNameServer.ps1 +++ b/NetScaler/Public/Remove-NSDnsNameServer.ps1 @@ -17,7 +17,7 @@ limitations under the License. function Remove-NSDnsNameServer { <# .SYNOPSIS - Remove a domain name server from NetScaler appliance. + Removes a domain name server from NetScaler appliance. .DESCRIPTION Remove a domain name server from NetScaler appliance. From 23f89ccc82d6637ccf9eaf8c32048df7b5ff7d2b Mon Sep 17 00:00:00 2001 From: Herrera Date: Mon, 17 Jul 2017 10:32:27 -0700 Subject: [PATCH 3/7] modified virtualserver functions --- NetScaler/Public/New-NSLBVirtualServer.ps1 | 16 ++++++--- NetScaler/Public/Set-NSLBVirtualServer.ps1 | 41 +++++++++++++++++----- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/NetScaler/Public/New-NSLBVirtualServer.ps1 b/NetScaler/Public/New-NSLBVirtualServer.ps1 index 1531c28..d705b1c 100644 --- a/NetScaler/Public/New-NSLBVirtualServer.ps1 +++ b/NetScaler/Public/New-NSLBVirtualServer.ps1 @@ -140,6 +140,10 @@ function New-NSLBVirtualServer { Minimum value = 0 Maximum value = 31536000 + .PARAMETER BackupVServer + Name of the backup virtual server to which to forward requests if the primary virtual server goes DOWN or reaches its spillover threshold. + Minimum length = 1 + .PARAMETER Passthru Return the load balancer server object. #> @@ -188,7 +192,11 @@ function New-NSLBVirtualServer { [int]$TimeOut = 2, [Parameter()] - [int]$ClientTimeout, + [int]$ClientTimeout, + + [Parameter()] + [string] + $BackupVServer, [Switch]$PassThru ) @@ -214,21 +222,21 @@ function New-NSLBVirtualServer { if ($PSBoundParameters.ContainsKey('PersistenceType')) { $params.Add('persistencetype', $PersistenceType) } - if ($PSBoundParameters.ContainsKey('RedirectFromPort')) { $params.Add('redirectfromport', $RedirectFromPort) } - if ($PSBoundParameters.ContainsKey('HTTPSRedirectURL')) { $params.Add('rediurl', $HTTPSRedirectURL) } - if ($PSBoundParameters.ContainsKey('Timeout')) { $params.Add('timeout', $Timeout) } if ($PSBoundParameters.ContainsKey('ClientTimeout')) { $params.Add('clttimeout', $ClientTimeout) } + if ($PSBoundParameters.ContainsKey('BackupVServer')) { + $params.Add('backupvserver', $BackupVServer) + } _InvokeNSRestApi -Session $Session -Method POST -Type lbvserver -Payload $params -Action add if ($PSBoundParameters.ContainsKey('PassThru')) { diff --git a/NetScaler/Public/Set-NSLBVirtualServer.ps1 b/NetScaler/Public/Set-NSLBVirtualServer.ps1 index 88ab0f7..af10f88 100644 --- a/NetScaler/Public/Set-NSLBVirtualServer.ps1 +++ b/NetScaler/Public/Set-NSLBVirtualServer.ps1 @@ -29,12 +29,12 @@ function Set-NSLBVirtualServer { .EXAMPLE Set-NSLBVirtualServer -Name 'vserver01' -Comment 'this is a comment' -PassThru - + Sets the comment for virtual server 'vserver01' and returns the updated object. .EXAMPLE Set-NSLBVirtualServer -Name 'vserver01' -IPAddress '11.11.11.11' -HttpRedirectURL "http://google.com" -Force - + Sets the IP address for virtual server 'vserver01' to '11.11.11.11' with a redirect to Google.com in case the backend services/service group are not available and suppresses confirmation. .PARAMETER Session @@ -44,7 +44,7 @@ function Set-NSLBVirtualServer { The name or names of the load balancer virtual servers to set. .PARAMETER PersistenceType - The type of persistence for the virtual server. Possible values = SOURCEIP, COOKIEINSERT, SSLSESSION, RULE, URLPASSIVE, CUSTOMSERVERID, DESTIP, SRCIPDESTIP, CALLID, RTSPSID, DIAMETER, NONE + The type of persistence for the virtual server. Possible values = SOURCEIP, COOKIEINSERT, SSLSESSION, RULE, URLPASSIVE, CUSTOMSERVERID, DESTIP, SRCIPDESTIP, CALLID, RTSPSID, DIAMETER, NONE .PARAMETER LBMethod The load balancing method of the virtual server. @@ -56,13 +56,22 @@ function Set-NSLBVirtualServer { The comment associated with the virtual server. .PARAMETER HttpRedirectURL - The URL to which to redirect traffic if the virtual server becomes unavailable. + The URL to which to redirect traffic if the virtual server becomes unavailable. .PARAMETER ICMPVSRResponse The URL to which to redirect traffic if the virtual server becomes unavailable. The dfault value is "Passive" .PARAMETER TimeOut - The time period for which a persistence session is in effect. The default value is 2 seconds. + The time period for which a persistence session is in effect. The default value is 2 seconds. + + .PARAMETER ClientTimeout + Idle time, in seconds, after which a client connection is terminated. + Minimum value = 0 + Maximum value = 31536000 + + .PARAMETER BackupVServer + Name of the backup virtual server to which to forward requests if the primary virtual server goes DOWN or reaches its spillover threshold. + Minimum length = 1 .PARAMETER Force Suppress confirmation when updating a virtual server. @@ -83,14 +92,14 @@ function Set-NSLBVirtualServer { [Parameter()] [ValidateSet('SOURCEIP', 'COOKIEINSERT', 'SSLSESSION', 'CUSTOMSERVERID', 'RULE', 'URLPASSIVE', 'DESTIP', 'SRCIPDESTIP', 'CALLID' ,'RTSPID', 'FIXSESSION', 'NONE')] [string] - $PersistenceType, + $PersistenceType, [ValidateScript({$_ -match [IPAddress]$_ })] [string]$IPAddress, [Parameter()] [string] - $HttpRedirectURL, + $HttpRedirectURL, [Parameter()] [ValidateLength(0, 256)] @@ -103,6 +112,13 @@ function Set-NSLBVirtualServer { [Parameter()] [int]$TimeOut = 2, + [Parameter()] + [int]$ClientTimeout, + + [Parameter()] + [string] + $BackupVServer, + [Switch]$Force, [Switch]$PassThru @@ -125,7 +141,7 @@ function Set-NSLBVirtualServer { } if ($PSBoundParameters.ContainsKey('PersistenceType')) { $params.Add('persistencetype', $PersistenceType) - } + } if ($PSBoundParameters.ContainsKey('Comment')) { $params.Add('comment', $Comment) } @@ -134,7 +150,14 @@ function Set-NSLBVirtualServer { } if ($PSBoundParameters.ContainsKey('HttpRedirectURL')) { $params.Add('redirurl', $HttpRedirectURL) - } + } + if ($PSBoundParameters.ContainsKey('ClientTimeout')) { + $params.Add('clttimeout', $ClientTimeout) + } + + if ($PSBoundParameters.ContainsKey('BackupVServer')) { + $params.Add('backupvserver', $BackupVServer) + } _InvokeNSRestApi -Session $Session -Method PUT -Type lbvserver -Payload $params -Action update From 65ba5c43bf14a8f79eba7ad22a8cbfb1e4d45f38 Mon Sep 17 00:00:00 2001 From: Herrera Date: Wed, 20 Sep 2017 08:53:26 -0700 Subject: [PATCH 4/7] modified and added new functions --- NetScaler/NetScaler.psd1 | 25 +++-- NetScaler/Public/Add-NSCertKeyPair.ps1 | 4 +- .../Public/Add-NSLBSSLCipherGroupBinding.ps1 | 83 ++++++++++++++ .../Public/Add-NSLBSSLCipherSuiteBinding.ps1 | 83 ++++++++++++++ ... => Add-NSLBServiceGroupMemberBinding.ps1} | 20 ++-- .../Public/Add-NSLBServiceMonitorBinding.ps1 | 101 ++++++++++++++++++ NetScaler/Public/Add-NSVLAN.ps1 | 4 +- .../Public/Get-NSLBSSLCipherGroupBinding.ps1 | 69 ++++++++++++ .../Public/Get-NSLBSSLCipherSuiteBinding.ps1 | 69 ++++++++++++ .../Get-NSLBServiceGroupMemberBinding.ps1 | 6 +- .../Get-NSLBServiceGroupMonitorBinding.ps1 | 4 +- .../Public/Get-NSLBServiceMonitorBinding.ps1 | 67 ++++++++++++ NetScaler/Public/Get-NSResponderHTMLPage.ps1 | 8 +- NetScaler/Public/Get-NSVLANBindings.ps1 | 2 +- NetScaler/Public/Import-NSCertFile.ps1 | 71 ++++++++++++ NetScaler/Public/New-NSLBService.ps1 | 90 ++++++++-------- NetScaler/Public/New-NSLBVirtualServer.ps1 | 42 +++++--- NetScaler/Public/New-NSResponderAction.ps1 | 30 +++--- NetScaler/Public/New-NSResponderHTMLPage.ps1 | 21 ++-- NetScaler/Public/New-NSResponderPolicy.ps1 | 9 ++ NetScaler/Public/New-NSSSLProfile.ps1 | 6 +- NetScaler/Public/Remove-NSCertFile.ps1 | 70 ++++++++++++ NetScaler/Public/Remove-NSDnsNameServer.ps1 | 56 +++++++--- .../Remove-NSLBSSLCipherGroupBinding.ps1 | 83 ++++++++++++++ .../Remove-NSLBSSLCipherSuiteBinding.ps1 | 83 ++++++++++++++ ...NSLBSSLVirtualServerCertificateBinding.ps1 | 83 ++++++++++++++ .../Remove-NSLBServiceGroupMemberBinding.ps1 | 17 +-- .../Remove-NSLBServiceMonitorBinding.ps1 | 74 +++++++++++++ .../Public/Remove-NSResponderHTMLPage.ps1 | 63 +++++++++++ .../Public/Remove-NSVLANInterfaceBinding.ps1 | 22 ++-- NetScaler/Public/Set-NSLBVirtualServer.ps1 | 14 ++- NetScaler/Public/Set-NSResponderAction.ps1 | 3 + NetScaler/Public/Set-NSResponderPolicy.ps1 | 14 ++- .../Public/Set-NSVLANInterfaceBinding.ps1 | 82 ++++++++++++++ 34 files changed, 1315 insertions(+), 163 deletions(-) create mode 100644 NetScaler/Public/Add-NSLBSSLCipherGroupBinding.ps1 create mode 100644 NetScaler/Public/Add-NSLBSSLCipherSuiteBinding.ps1 rename NetScaler/Public/{New-NSLBServiceGroupMember.ps1 => Add-NSLBServiceGroupMemberBinding.ps1} (91%) create mode 100644 NetScaler/Public/Add-NSLBServiceMonitorBinding.ps1 create mode 100644 NetScaler/Public/Get-NSLBSSLCipherGroupBinding.ps1 create mode 100644 NetScaler/Public/Get-NSLBSSLCipherSuiteBinding.ps1 create mode 100644 NetScaler/Public/Get-NSLBServiceMonitorBinding.ps1 create mode 100644 NetScaler/Public/Import-NSCertFile.ps1 create mode 100644 NetScaler/Public/Remove-NSCertFile.ps1 create mode 100644 NetScaler/Public/Remove-NSLBSSLCipherGroupBinding.ps1 create mode 100644 NetScaler/Public/Remove-NSLBSSLCipherSuiteBinding.ps1 create mode 100644 NetScaler/Public/Remove-NSLBSSLVirtualServerCertificateBinding.ps1 create mode 100644 NetScaler/Public/Remove-NSLBServiceMonitorBinding.ps1 create mode 100644 NetScaler/Public/Remove-NSResponderHTMLPage.ps1 create mode 100644 NetScaler/Public/Set-NSVLANInterfaceBinding.ps1 diff --git a/NetScaler/NetScaler.psd1 b/NetScaler/NetScaler.psd1 index 2590b6e..56f0720 100644 --- a/NetScaler/NetScaler.psd1 +++ b/NetScaler/NetScaler.psd1 @@ -12,7 +12,7 @@ RootModule = 'NetScaler.psm1' # Version number of this module. -ModuleVersion = '1.5.1' +ModuleVersion = '1.5.2' # ID used to uniquely identify this module GUID = 'bd4390dc-a8ad-4bce-8d69-f53ccf8e4163' @@ -72,7 +72,11 @@ FunctionsToExport = @( 'Add-NSDnsNameServer', 'Add-NSDnsSuffix', 'Add-NSIPResource', + 'Add-NSLBServiceGroupMemberBinding', 'Add-NSLBServiceGroupMonitorBinding', + 'Add-NSLBServiceMonitorBinding', + 'Add-NSLBSSLCipherGroupBinding', + 'Add-NSLBSSLCipherSuiteBinding', 'Add-NSLBSSLVirtualServerCertificateBinding', 'Add-NSLBVirtualServerBinding', 'Add-NSCSVirtualServerPolicyBinding', @@ -127,6 +131,9 @@ FunctionsToExport = @( 'Get-NSLBServiceGroup', 'Get-NSLBServiceGroupMemberBinding', 'Get-NSLBServiceGroupMonitorBinding', + 'Get-NSLBServiceMonitorBinding', + 'Get-NSLBSSLCipherGroupBinding', + 'Get-NSLBSSLCipherSuiteBinding', 'Get-NSLBSSLVirtualServer', 'Get-NSLBSSLVirtualServerCertificateBinding', 'Get-NSLBSSLVirtualServerProfile', @@ -163,6 +170,7 @@ FunctionsToExport = @( 'Get-NSVPNVirtualServer', 'Get-NSVPNVirtualServerBinding', 'Get-NSVPNVirtualServerTheme', + 'Import-NSCertFile', 'Install-NSLicense', 'Invoke-Nitro', 'New-NSBackup', @@ -173,7 +181,6 @@ FunctionsToExport = @( 'New-NSLBServer', 'New-NSLBService', 'New-NSLBServiceGroup', - 'New-NSLBServiceGroupMember', 'New-NSLBServiceGroupMonitor', 'New-NSLBVirtualServer', 'New-NSLDAPAuthenticationPolicy', @@ -190,6 +197,7 @@ FunctionsToExport = @( 'New-NSVPNSessionProfile', 'New-NSVPNVirtualServer', 'Remove-NSBackup', + 'Remove-NSCertFile', 'Remove-NSCertKeyPair', 'Remove-NSDnsNameServer', 'Remove-NSDnsSuffix', @@ -200,17 +208,22 @@ FunctionsToExport = @( 'Remove-NSLBServiceGroup', 'Remove-NSLBServiceGroupMemberBinding', 'Remove-NSLBServiceGroupMonitorBinding', + 'Remove-NSLBServiceMonitorBinding', 'Remove-NSLBVirtualServer', 'Remove-NSLBVirtualServerBinding', 'Remove-NSLBVirtualServerResponderPolicyBinding', + 'Remove-NSLBSSLCipherGroupBinding', + 'Remove-NSLBSSLCipherSuiteBinding', + 'Remove-NSLBSSLVirtualServerCertificateBinding', 'Remove-NSLBSSLVirtualServerProfile', 'Remove-NSLDAPAuthenticationPolicy', 'Remove-NSLDAPAuthenticationServer', 'Remove-NSNTPServer', 'Remove-NSResponderAction', + 'Remove-NSResponderHTMLPage', 'Remove-NSResponderPolicy', 'Remove-NSRewritePolicy', - 'Remove-NSRewriteAction', + 'Remove-NSRewriteAction', 'Remove-NSSSLCertificateLink', 'Remove-NSSSLProfile', 'Remove-NSSystemFile', @@ -222,7 +235,7 @@ FunctionsToExport = @( 'Set-NSCertKeyPair', 'Save-NSConfig', 'Set-NSHostname', - 'Set-NSIPResource', + 'Set-NSIPResource', 'Set-NSLBMonitor', 'Set-NSLBServer', 'Set-NSLBService', @@ -232,10 +245,10 @@ FunctionsToExport = @( 'Set-NSLBVirtualServer', 'Set-NSMode', 'Set-NSNTPServer', - 'Set-NSResponderAction', + 'Set-NSResponderAction', 'Set-NSResponderPolicy', 'Set-NSRewriteAction', - 'Set-NSRewritePolicy', + 'Set-NSRewritePolicy', 'Set-NSSSLProfile', 'Set-NSVLAN', 'Set-NSTimeZone', diff --git a/NetScaler/Public/Add-NSCertKeyPair.ps1 b/NetScaler/Public/Add-NSCertKeyPair.ps1 index 380d230..ad1f62b 100644 --- a/NetScaler/Public/Add-NSCertKeyPair.ps1 +++ b/NetScaler/Public/Add-NSCertKeyPair.ps1 @@ -71,10 +71,10 @@ function Add-NSCertKeyPair { param( $Session = $script:session, - [Parameter()] + [Parameter(Mandatory)] [string]$CertKeyName, - [Parameter()] + [Parameter(Mandatory)] [string]$CertPath, [Parameter()] diff --git a/NetScaler/Public/Add-NSLBSSLCipherGroupBinding.ps1 b/NetScaler/Public/Add-NSLBSSLCipherGroupBinding.ps1 new file mode 100644 index 0000000..14c387f --- /dev/null +++ b/NetScaler/Public/Add-NSLBSSLCipherGroupBinding.ps1 @@ -0,0 +1,83 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Add-NSLBSSLCipherGroupBinding { + <# + .SYNOPSIS + Adds a new load balancer server to cipher group binding. + + .DESCRIPTION + Adds a new load balancer server to cipher group binding. + + .EXAMPLE + Add-NSLBSSLCipherBinding -VirtualServerName 'vserver01' -CipherName 'somecipher' + + Adds the binding of the SSL cipher group 'somecipher' to virtual server 'vserver01'. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VirtualServerName + Name of the SSL virtual server + + .PARAMETER CipherName + The cipher group/alias/individual cipher configuration. + + .PARAMETER Passthru + Return the load balancer server object. + + .PARAMETER Force + Suppress confirmation adding certificate binding. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Medium', DefaultParameterSetName='servicegroup')] + param( + $Session = $script:session, + + [parameter(Mandatory=$True)] + [string]$VirtualServerName = (Read-Host -Prompt 'LB virtual server name'), + + [parameter(Mandatory=$True)] + [string]$CipherName, + + [Switch]$PassThru, + + [switch]$Force + ) + + begin { + _AssertSessionActive + } + + process { + if ($Force -or $PSCmdlet.ShouldProcess($VirtualServerName, 'Add a Cipher Group Binding')) { + try { + + $params = @{ + vservername = $VirtualServerName + ciphername = $CipherName + } + + _InvokeNSRestApi -Session $Session -Method PUT -Type sslvserver_sslcipher_binding -Payload $params + + if ($PSBoundParameters.ContainsKey('PassThru')) { + return Get-NSLBSSLCipherGroupBinding -Session $Session -VirtualServerName $VirtualServerName + } + } catch { + throw $_ + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Add-NSLBSSLCipherSuiteBinding.ps1 b/NetScaler/Public/Add-NSLBSSLCipherSuiteBinding.ps1 new file mode 100644 index 0000000..f8dbfc6 --- /dev/null +++ b/NetScaler/Public/Add-NSLBSSLCipherSuiteBinding.ps1 @@ -0,0 +1,83 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Add-NSLBSSLCipherSuiteBinding { + <# + .SYNOPSIS + Adds a new load balancer server to cipher suite binding. + + .DESCRIPTION + Adds a new load balancer server to cipher suite binding. + + .EXAMPLE + Add-NSLBSSLCipherSuiteBinding -VirtualServerName 'vserver01' -CipherName 'somecipher' + + Adds the binding of the SSL cipher suite 'somecipher' to virtual server 'vserver01'. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VirtualServerName + Name of the SSL virtual server + + .PARAMETER CipherName + The cipher group/alias/individual cipher configuration. + + .PARAMETER Passthru + Return the load balancer server object. + + .PARAMETER Force + Suppress confirmation adding certificate binding. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Medium', DefaultParameterSetName='servicegroup')] + param( + $Session = $script:session, + + [parameter(Mandatory=$True)] + [string]$VirtualServerName = (Read-Host -Prompt 'LB virtual server name'), + + [parameter(Mandatory=$True)] + [string]$CipherName, + + [Switch]$PassThru, + + [switch]$Force + ) + + begin { + _AssertSessionActive + } + + process { + if ($Force -or $PSCmdlet.ShouldProcess($VirtualServerName, 'Add a Cipher Suite Binding')) { + try { + + $params = @{ + vservername = $VirtualServerName + ciphername = $CipherName + } + + _InvokeNSRestApi -Session $Session -Method PUT -Type sslvserver_sslciphersuite_binding -Payload $params + + if ($PSBoundParameters.ContainsKey('PassThru')) { + return Get-NSLBSSLCipherSuiteBinding -Session $Session -VirtualServerName $VirtualServerName + } + } catch { + throw $_ + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/New-NSLBServiceGroupMember.ps1 b/NetScaler/Public/Add-NSLBServiceGroupMemberBinding.ps1 similarity index 91% rename from NetScaler/Public/New-NSLBServiceGroupMember.ps1 rename to NetScaler/Public/Add-NSLBServiceGroupMemberBinding.ps1 index 8a1151d..d978963 100644 --- a/NetScaler/Public/New-NSLBServiceGroupMember.ps1 +++ b/NetScaler/Public/Add-NSLBServiceGroupMemberBinding.ps1 @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. #> -function New-NSLBServiceGroupMember { +function Add-NSLBServiceGroupMemberBinding { <# .SYNOPSIS Adds a load balancer server to a service group. @@ -29,13 +29,13 @@ function New-NSLBServiceGroupMember { .EXAMPLE $x = New-NSLBServiceGroupMember -Name 'sg01' -ServerName 'server01' -State 'DISABLED' -PassThru - + Associates server 'server01' with service group 'sg01' initially in a DISABLED state and return the object. .PARAMETER Session The NetScaler session object. - .PARAMETER Name + .PARAMETER ServiceName The name of the service group to associated the server with. .PARAMETER ServerName @@ -47,8 +47,8 @@ function New-NSLBServiceGroupMember { Range 1 - 65535 .PARAMETER Weight - Weight to assign to the servers in the service group. - Specifies the capacity of the servers relative to the other servers in the load balancing configuration. + Weight to assign to the servers in the service group. + Specifies the capacity of the servers relative to the other servers in the load balancing configuration. The higher the weight, the higher the percentage of requests sent to the service. Minimum value = 1 @@ -58,7 +58,7 @@ function New-NSLBServiceGroupMember { The identifier for the service. This is used when the persistency type is set to Custom Server ID. .PARAMETER HashId - The hash identifier for the service. This must be unique for each service. + The hash identifier for the service. This must be unique for each service. This parameter is used by hash based load balancing methods. Minimum value = 1 @@ -75,7 +75,7 @@ function New-NSLBServiceGroupMember { [parameter(Mandatory, ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName = $true)] [Alias('ServiceGroupName')] - [string[]]$Name, + [string[]]$ServiceName, [Parameter(Mandatory)] [string[]]$ServerName, @@ -102,7 +102,7 @@ function New-NSLBServiceGroupMember { } process { - foreach ($item in $Name) { + foreach ($item in $ServiceName) { foreach ($member in $ServerName) { if ($PSCmdlet.ShouldProcess($item, "Add Service Group Member: $Member")) { try { @@ -110,7 +110,7 @@ function New-NSLBServiceGroupMember { servicegroupname = $item servername = $member port = $Port - state = $State + state = $State weight = $Weight serverid = $ServerId hashid = $Hashid @@ -118,7 +118,7 @@ function New-NSLBServiceGroupMember { _InvokeNSRestApi -Session $Session -Method POST -Type servicegroup_servicegroupmember_binding -Payload $params -Action add if ($PSBoundParameters.ContainsKey('PassThru')) { - return Get-NSLBServiceGroupMemberBinding -Session $session -Name $item + return Get-NSLBServiceGroupMemberBinding -Session $session -ServerName $item } } catch { throw $_ diff --git a/NetScaler/Public/Add-NSLBServiceMonitorBinding.ps1 b/NetScaler/Public/Add-NSLBServiceMonitorBinding.ps1 new file mode 100644 index 0000000..0fc74e8 --- /dev/null +++ b/NetScaler/Public/Add-NSLBServiceMonitorBinding.ps1 @@ -0,0 +1,101 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Add-NSLBServiceMonitorBinding { + <# + .SYNOPSIS + Adds a new service group monitor binding. + + .DESCRIPTION + Adds a new service group monitor binding. + + .EXAMPLE + Add-NSLBServiceMonitorBinding -ServiceName 'svc01' -MonitorName 'mon01' + + Bind the monitor 'mon01' to service 'svc01'. + + .EXAMPLE + Add-NSLBServiceMonitorBinding -ServiceName 'svc01' -MonitorName 'mon01' -Force -PassThru + + Bind the monitor 'mon01' to service 'svc01', suppress the confirmation and return the result. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER ServiceName + Name of the service to which to bind a policy or monitor. + + .PARAMETER MonitorName + Name of the monitor to bind to the service. + + .PARAMETER Passive + Indicates if load monitor is passive. A passive load monitor does not remove service from LB decision when threshold is breached. + + .PARAMETER Weight + Weight to assign to the monitor-service binding. When a monitor is UP, the weight assigned to its binding with the service determines how much the monitor contributes toward keeping the health of the service above the value configured for the Monitor Threshold parameter. + Minimum value = 1 + Maximum value = 100 + + .PARAMETER Force + Suppress confirmation when binding the certificate key to the virtual server. + + .PARAMETER Passthru + Return the load balancer server object. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] + param( + $Session = $script:session, + + [parameter(Mandatory)] + [string]$ServiceName, + + [parameter(Mandatory)] + [string]$MonitorName, + + [ValidateRange(1,100)] + [int]$Weight, + + [Switch]$Force, + + [Switch]$PassThru + ) + + begin { + _AssertSessionActive + } + + process { + if ($Force -or $PSCmdlet.ShouldProcess($ServiceName, 'Add Monitor Binding to Service')) { + try { + $params = @{ + name = $ServiceName + monitor_name = $MonitorName + } + if ($PSBoundParameters.ContainsKey('Weight')) { + $params.Add('weight', $Weight) + } + + _InvokeNSRestApi -Session $Session -Method PUT -Type service_lbmonitor_binding -Payload $params + + # if ($PSBoundParameters.ContainsKey('PassThru')) { + # return Get-NSLBServiceMonitorBinding -Session $Session -ServiceName $ServiceName + # } + } catch { + throw $_ + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Add-NSVLAN.ps1 b/NetScaler/Public/Add-NSVLAN.ps1 index edf04fe..d8361f5 100644 --- a/NetScaler/Public/Add-NSVLAN.ps1 +++ b/NetScaler/Public/Add-NSVLAN.ps1 @@ -40,7 +40,7 @@ function Add-NSVLAN { Enable all IPv6 dynamic routing protocols on this VLAN. Note: For the ENABLED setting to work, you must configure IPv6 dynamic routing protocols from the VTYSH command line. Possible values = ENABLED, DISABLED .PARAMETER MTU - Specifies the maximum transmission unit (MTU), in bytes. + Specifies the maximum transmission unit (MTU), in bytes. .PARAMETER Force Suppress confirmation when adding a DNS suffix. @@ -50,7 +50,7 @@ function Add-NSVLAN { $Session = $script:session, [parameter(Mandatory, ValueFromPipeline)] - [int]$VLANID, + [int[]]$VLANID, [parameter(Mandatory, ValueFromPipeline)] [string[]]$AliasName, diff --git a/NetScaler/Public/Get-NSLBSSLCipherGroupBinding.ps1 b/NetScaler/Public/Get-NSLBSSLCipherGroupBinding.ps1 new file mode 100644 index 0000000..2052345 --- /dev/null +++ b/NetScaler/Public/Get-NSLBSSLCipherGroupBinding.ps1 @@ -0,0 +1,69 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Get-NSLBSSLCipherGroupBinding { + <# + .SYNOPSIS + Gets the specified load balancer SSL virtual server object binding to a cipher group. + + .DESCRIPTION + Gets the specified load balancer SSL virtual server object binding to a cipher group + + .EXAMPLE + Get-NSLBSSLCipherBinding + + Get the cypher group bindings for all load balancer SSL virtual server objects. + + .EXAMPLE + Get-NSLBSSLCipherBinding -VirtualServerName 'vserver01' + + Get the cipher group bindings for the load balancer SSL virtual server named 'vserver01'. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VirtualServerName + The name or names of the load balancer SSL virtual server to get. + #> + [cmdletbinding()] + param( + $Session = $script:session, + + [Parameter(Position=0)] + [string]$VirtualServerName + ) + + begin { + _AssertSessionActive + $response = @() + } + + process { + # If we specified a virtual server name, return only those details + # Otherwise, get everything + if ($PSBoundParameters.ContainsKey('VirtualServerName')) { + $response = _InvokeNSRestApi -Session $Session -Method Get -Type sslvserver_sslcipher_binding -Action Get -Resource $VirtualServerName + } else { + $response = _InvokeNSRestApi -Session $Session -Method Get -Type sslvserver_sslcipher_binding -Action Get + } + + if ($response.errorcode -ne 0) { throw $response } + + if ($response.psobject.properties | where name -eq sslvserver_sslcipher_binding) { + return $response.sslvserver_sslcipher_binding + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Get-NSLBSSLCipherSuiteBinding.ps1 b/NetScaler/Public/Get-NSLBSSLCipherSuiteBinding.ps1 new file mode 100644 index 0000000..d741159 --- /dev/null +++ b/NetScaler/Public/Get-NSLBSSLCipherSuiteBinding.ps1 @@ -0,0 +1,69 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Get-NSLBSSLCipherSuiteBinding { + <# + .SYNOPSIS + Gets the specified load balancer SSL virtual server object. + + .DESCRIPTION + Gets the specified load balancer SSL virtual server object. + + .EXAMPLE + Get-NSLBSSLCipherSuiteBinding + + Get the cypher suite bindings for all load balancer SSL virtual server objects. + + .EXAMPLE + Get-NSLBSSLCipherSuiteBinding -VirtualServerName 'vserver01' + + Get the cipher suite bindings for the load balancer SSL virtual server named 'vserver01'. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VirtualServerName + The name or names of the load balancer SSL virtual server to get. + #> + [cmdletbinding()] + param( + $Session = $script:session, + + [Parameter(Position=0)] + [string]$VirtualServerName + ) + + begin { + _AssertSessionActive + $response = @() + } + + process { + # If we specified a virtual server name, return only those details + # Otherwise, get everything + if ($PSBoundParameters.ContainsKey('VirtualServerName')) { + $response = _InvokeNSRestApi -Session $Session -Method Get -Type sslvserver_sslciphersuite_binding -Action Get -Resource $VirtualServerName + } else { + $response = _InvokeNSRestApi -Session $Session -Method Get -Type sslvserver_sslciphersuite_binding -Action Get + } + + if ($response.errorcode -ne 0) { throw $response } + + if ($response.psobject.properties | where name -eq sslvserver_sslciphersuite_binding) { + return $response.sslvserver_sslciphersuite_binding + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Get-NSLBServiceGroupMemberBinding.ps1 b/NetScaler/Public/Get-NSLBServiceGroupMemberBinding.ps1 index 7cb9174..24d3a2d 100644 --- a/NetScaler/Public/Get-NSLBServiceGroupMemberBinding.ps1 +++ b/NetScaler/Public/Get-NSLBServiceGroupMemberBinding.ps1 @@ -39,7 +39,7 @@ function Get-NSLBServiceGroupMemberBinding { [parameter(Mandatory, ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName)] [alias('servicegroupname')] - [string[]]$Name + [string[]]$ServiceName ) begin { @@ -47,9 +47,9 @@ function Get-NSLBServiceGroupMemberBinding { } process { - foreach ($item in $Name) { + foreach ($item in $ServiceName) { try { - $bindings = _InvokeNSRestApi -Session $Session -Method Get -Type servicegroup_servicegroupmember_binding -Resource $item -Action Get + $bindings = _InvokeNSRestApi -Session $Session -Method Get -Type servicegroup_servicegroupmember_binding -Resource $item -Action Get return $bindings.servicegroup_servicegroupmember_binding } catch { throw $_ diff --git a/NetScaler/Public/Get-NSLBServiceGroupMonitorBinding.ps1 b/NetScaler/Public/Get-NSLBServiceGroupMonitorBinding.ps1 index b808cb9..46fa54f 100644 --- a/NetScaler/Public/Get-NSLBServiceGroupMonitorBinding.ps1 +++ b/NetScaler/Public/Get-NSLBServiceGroupMonitorBinding.ps1 @@ -41,7 +41,7 @@ function Get-NSLBServiceGroupMonitorBinding { $Session = $script:session, [parameter(Mandatory, ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName)] - [string[]]$Name, + [string[]]$ServiceGroupName, [parameter()] [string]$MonitorName @@ -58,7 +58,7 @@ function Get-NSLBServiceGroupMonitorBinding { if ($PSBoundParameters.ContainsKey('MonitorName')) { $Filters['monitor_name'] = $MonitorName } - _InvokeNSRestApiGet -Session $Session -Type servicegroup_lbmonitor_binding -Name $Name -Filters $Filters + _InvokeNSRestApiGet -Session $Session -Type servicegroup_lbmonitor_binding -Name $ServiceGroupName -Filters $Filters } catch { throw $_ diff --git a/NetScaler/Public/Get-NSLBServiceMonitorBinding.ps1 b/NetScaler/Public/Get-NSLBServiceMonitorBinding.ps1 new file mode 100644 index 0000000..d582431 --- /dev/null +++ b/NetScaler/Public/Get-NSLBServiceMonitorBinding.ps1 @@ -0,0 +1,67 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Get-NSLBServiceMonitorBinding { + <# + .SYNOPSIS + Gets the monitor binding for a service. + + .DESCRIPTION + Gets the monitor binding for a service. + + .EXAMPLE + Get-NSLBServiceMonitorBinding -ServiceName $svc + + Gets the monitor bindings for the 'svc' service. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER ServiceName + The name or names of the monitor to get the service binding for. + + .PARAMETER MonitorName + Filters the returned monitors to only include the name specified + #> + [cmdletbinding()] + param( + $Session = $script:session, + + [parameter(Mandatory, ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName)] + [string[]]$ServiceName, + + [parameter()] + [string]$MonitorName + ) + + begin { + _AssertSessionActive + } + + process { + try { + # Contruct a filter hash if we specified any filters + $Filters = @{} + if ($PSBoundParameters.ContainsKey('MonitorName')) { + $Filters['monitor_name'] = $MonitorName + } + _InvokeNSRestApiGet -Session $Session -Type service_lbmonitor_binding -Name $ServiceName -Filters $Filters + } + catch { + throw $_ + } + } +} diff --git a/NetScaler/Public/Get-NSResponderHTMLPage.ps1 b/NetScaler/Public/Get-NSResponderHTMLPage.ps1 index a11e563..7f7aa97 100644 --- a/NetScaler/Public/Get-NSResponderHTMLPage.ps1 +++ b/NetScaler/Public/Get-NSResponderHTMLPage.ps1 @@ -48,11 +48,7 @@ function Get-NSResponderHTMLPage { } process { - # Contruct a filter hash if we specified any filters - # $Filters = @{} - # if ($PSBoundParameters.ContainsKey('Name')) { - # $Filters['name'] = $Name - # } - _InvokeNSRestApiGet -Session $Session -Type responderhtmlpage -Name $Name #-Filters $Filters + $response = _InvokeNSRestApiGet -Session $Session -Type responderhtmlpage -Name $Name + $response.name } } \ No newline at end of file diff --git a/NetScaler/Public/Get-NSVLANBindings.ps1 b/NetScaler/Public/Get-NSVLANBindings.ps1 index 915564e..927b0d5 100644 --- a/NetScaler/Public/Get-NSVLANBindings.ps1 +++ b/NetScaler/Public/Get-NSVLANBindings.ps1 @@ -51,7 +51,7 @@ function Get-NSVLANBindings { if ($PSCmdlet.ShouldProcess($item, 'Get VLAN information')) { try { $t = _InvokeNSRestApi -Session $Session -Method GET -Type vlan_binding -Resource $item -Action get - $t.vlan_binding | fl + # $t.vlan_binding | fl } catch { throw $_ diff --git a/NetScaler/Public/Import-NSCertFile.ps1 b/NetScaler/Public/Import-NSCertFile.ps1 new file mode 100644 index 0000000..984d890 --- /dev/null +++ b/NetScaler/Public/Import-NSCertFile.ps1 @@ -0,0 +1,71 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Import-NSCertFile { + <# + .SYNOPSIS + Add server certificate to NetScaler appliance. + + .DESCRIPTION + Add server certificate to NetScaler appliance. + + .EXAMPLE + Import-NSCertFile -CertName somecert.pem -Location 'http://website.local/certs/somecert.pem' + + Imports the appliance. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER CertName + Name to assign to the imported certificate file. Must begin with an ASCII alphanumeric or underscore (_) character, and must contain only ASCII alphanumeric, underscore, hash (#), period (.), space, colon (:), at (@), equals (=), and hyphen (-) characters. The following requirement applies only to the NetScaler CLI: If the name includes one or more spaces, enclose the name in double or single quotation marks (for example, "my file" or 'my file'). + Minimum length = 1 + Maximum length = 31 + + .PARAMETER Location + URL specifying the protocol, host, and path, including file name, to the certificate file to be imported. For example, http://www.example.com/cert_file. NOTE: The import fails if the object to be imported is on an HTTPS server that requires client certificate authentication for access. + Minimum length = 1 + Maximum length = 2047 + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [Parameter()] + [string]$CertName, + + [Parameter()] + [string]$Location + ) + + begin { + _AssertSessionActive + } + + process { + if ($PSCmdlet.ShouldProcess($CertName, 'Import SSL certificate')) { + try { + $params = @{ + name = $CertName + src = $Location + } + $response = _InvokeNSRestApi -Session $Session -Method POST -Type sslcertfile -Payload $params -Action import + } catch { + throw $_ + } + } + } +} diff --git a/NetScaler/Public/New-NSLBService.ps1 b/NetScaler/Public/New-NSLBService.ps1 index 3ad081c..0acfedc 100644 --- a/NetScaler/Public/New-NSLBService.ps1 +++ b/NetScaler/Public/New-NSLBService.ps1 @@ -29,7 +29,7 @@ function New-NSLBService { .EXAMPLE 'service01' | New-NSLBService -ServiceType HTTP -Comment 'test service' - + Creates a new HTTP service called 'service01' with a comment. .PARAMETER Session @@ -47,7 +47,7 @@ function New-NSLBService { .PARAMETER IPAddress IP to assign to the service. Cannot be used in combination with the 'ServerName' option - Minimum length = 1 + Minimum length = 1 .PARAMETER Port Port number of the service. @@ -71,10 +71,10 @@ function New-NSLBService { Possible values = ENABLED, DISABLED .PARAMETER HealthMonitor - Monitor the health of this service. - Available settings function as follows: - YES - Send probes to check the health of the service. - NO - Do not send probes to check the health of the service. + Monitor the health of this service. + Available settings function as follows: + YES - Send probes to check the health of the service. + NO - Do not send probes to check the health of the service. With the NO option, the appliance shows the service as UP at all times. Default value: YES Possible values = YES, NO @@ -98,20 +98,20 @@ function New-NSLBService { Possible values = ON, OFF .PARAMETER UseProxyPort - Use the proxy port as the source port when initiating connections with the server. - With the NO setting, the client-side connection port is used as the source port for the server-side connection. + Use the proxy port as the source port when initiating connections with the server. + With the NO setting, the client-side connection port is used as the source port for the server-side connection. Note: This parameter is available only when the Use Source IP (USIP) parameter is set to YES. Possible values = YES, NO .PARAMETER DownStateFlush - Flush all active transactions associated with all the services in the service whose state transitions from UP to DOWN. + Flush all active transactions associated with all the services in the service whose state transitions from UP to DOWN. Note: Do not enable this option for applications that must complete their transactions. Default value: ENABLED Possible values = ENABLED, DISABLED .PARAMETER UseClientIP - Use client's IP address as the source IP address when initiating connection to the server. - With the NO setting, which is the default, a mapped IP (MIP) address or subnet IP (SNIP) address + Use client's IP address as the source IP address when initiating connection to the server. + With the NO setting, which is the default, a mapped IP (MIP) address or subnet IP (SNIP) address is used as the source IP address to initiate server side connections. Possible values = YES, NO @@ -132,9 +132,9 @@ function New-NSLBService { Possible values = ENABLED, DISABLED .PARAMETER ClientIPHeader - Name of the HTTP header whose value must be set to the IP address of the client. - Used with the Client IP parameter. If client IP insertion is enabled, and the - client IP header is not specified, the value of Client IP Header parameter or the + Name of the HTTP header whose value must be set to the IP address of the client. + Used with the Client IP parameter. If client IP insertion is enabled, and the + client IP header is not specified, the value of Client IP Header parameter or the value set by the set ns config command is used as client's IP header name. Minimum length = 1 @@ -144,7 +144,7 @@ function New-NSLBService { .PARAMETER PathMonitorIndividual Individual Path monitoring decisions. - Possible values = YES, NO + Possible values = YES, NO .PARAMETER RTPSessionIDRemap Enable RTSP session ID mapping for the service. @@ -156,17 +156,17 @@ function New-NSLBService { Default value: "None" .PARAMETER ServerID - The identifier for the service. This is used when the persistency type is set to Custom Server ID. + The identifier for the service. This is used when the persistency type is set to Custom Server ID. .PARAMETER MaxBandwidthKbps Maximum bandwidth, in Kbps, allocated for all the services in the service group. Minimum value = 0 - Maximum value = 4294967287 + Maximum value = 4294967287 .PARAMETER AccessDown Use Layer 2 mode to bridge the packets sent to this service if it is marked as DOWN. If the service is DOWN, and this parameter is disabled, the packets are dropped. Default value: NO - Possible values = YES, NO + Possible values = YES, NO .PARAMETER TCPProfileName Name of the TCP profile that contains TCP configuration settings for the service. @@ -191,7 +191,7 @@ function New-NSLBService { Possible values = ENABLED, DISABLED .PARAMETER MonitorThreshold - Minimum sum of weights of the monitors that are bound to this service. + Minimum sum of weights of the monitors that are bound to this service. Used to determine whether to mark a service as UP or DOWN. Minimum value = 0 Maximum value = 65535 @@ -212,7 +212,7 @@ function New-NSLBService { Minimum value = 0 Maximum value = 31536000 - .PARAMETER ServerIdleTimeout + .PARAMETER ServerIdleTimeout Time, in seconds, after which to terminate an idle server connection. Minimum value = 0 Maximum value = 31536000 @@ -295,10 +295,10 @@ function New-NSLBService { [string]$PathMonitor, [ValidateSet('YES', 'NO')] - [string]$PathMonitorIndividual, + [string]$PathMonitorIndividual, [ValidateSet('On', 'OFF')] - [string]$RTPSessionIDRemap = 'OFF', + [string]$RTPSessionIDRemap = 'OFF', [string]$CustomServerID = 'None', @@ -306,9 +306,9 @@ function New-NSLBService { [int]$MaxBandwidthKbps, [ValidateSet('YES', 'NO')] - [string]$AccessDown = 'No', + [string]$AccessDown = 'No', - [string]$TCPProfileName, + [string]$TCPProfileName, [string]$HTTPProfileName, @@ -317,13 +317,13 @@ function New-NSLBService { [ValidateRange(0, 4294967287)] [int]$HashID, - [string]$ProcessLocal, + [string]$ProcessLocal, [ValidateRange(0, 4294967287)] - [int]$TrafficDomain, + [int]$TrafficDomain, [ValidateRange(0, 65535)] - [int]$ServerID, + [int]$ServerID, [ValidateRange(0, 65535)] [int]$MonitorThreshold, @@ -361,46 +361,46 @@ function New-NSLBService { } if ($PSBoundParameters.ContainsKey('Cacheable')) { $params.Add('cacheable', $Cacheable) - } + } if ($PSBoundParameters.ContainsKey('HealthMonitor')) { $params.Add('healthmonitor', $HealthMonitor) - } + } if ($PSBoundParameters.ContainsKey('AppFlowLog')) { $params.Add('appflowlog', $AppFlowLog) - } + } if ($PSBoundParameters.ContainsKey('SureConnect')) { $params.Add('sc', $SureConnect) - } + } if ($PSBoundParameters.ContainsKey('SurgeProtection')) { $params.Add('sp', $SurgeProtection) - } + } if ($PSBoundParameters.ContainsKey('UseProxyPort')) { $params.Add('useproxyport', $UseProxyPort) - } + } if ($PSBoundParameters.ContainsKey('DownStateFlush')) { $params.Add('downstateflush', $DownStateFlush) - } + } if ($PSBoundParameters.ContainsKey('UseClientIP')) { $params.Add('usip', $UseClientIP) - } + } if ($PSBoundParameters.ContainsKey('ClientKeepAlive')) { $params.Add('cka', $ClientKeepAlive) - } + } if ($PSBoundParameters.ContainsKey('TCPBuffering')) { $params.Add('tcpb', $TCPBuffering) - } + } if ($PSBoundParameters.ContainsKey('ClientIP')) { $params.Add('cip', $ClientIP) - } + } if ($PSBoundParameters.ContainsKey('ClientIdleTimeout')) { $params.Add('clttimeout', $ClientIdleTimeout) - } + } if ($PSBoundParameters.ContainsKey('ServerIdleTimeout')) { $params.Add('svrtimeout', $ServerIdleTimeout) - } + } if ($PSBoundParameters.ContainsKey('IPAddress')) { $params.Add('ip', $IPAddress) - } + } if ($PSBoundParameters.ContainsKey('HTTPCompression')) { $params.Add('cmp', $HTTPCompression) } @@ -436,19 +436,19 @@ function New-NSLBService { } if ($PSBoundParameters.ContainsKey('TCPProfileName')) { $params.Add('tcpprofilename', $TCPProfileName) - } + } if ($PSBoundParameters.ContainsKey('HTTPProfileName')) { $params.Add('httpprofilename', $HTTPProfileName) } if ($PSBoundParameters.ContainsKey('NetProfileName')) { $params.Add('netprofilename', $NetProfileName) - } + } if ($PSBoundParameters.ContainsKey('TrafficDomain')) { $params.Add('td', $TrafficDomain) - } + } if ($PSBoundParameters.ContainsKey('ProcessLocal')) { $params.Add('processlocal', $ProcessLocal) - } + } if ($PSBoundParameters.ContainsKey('MonitorThreshold')) { $params.Add('monthreshold', $MonitorThreshold) } diff --git a/NetScaler/Public/New-NSLBVirtualServer.ps1 b/NetScaler/Public/New-NSLBVirtualServer.ps1 index d705b1c..95ff382 100644 --- a/NetScaler/Public/New-NSLBVirtualServer.ps1 +++ b/NetScaler/Public/New-NSLBVirtualServer.ps1 @@ -52,7 +52,7 @@ function New-NSLBVirtualServer { .PARAMETER NonAddressable Bypasses the need for an IPAddress and port for the virtual server to configure it as "Non Addressable" - + .PARAMETER Comment Any comments that you might want to associate with the virtual server. @@ -142,7 +142,12 @@ function New-NSLBVirtualServer { .PARAMETER BackupVServer Name of the backup virtual server to which to forward requests if the primary virtual server goes DOWN or reaches its spillover threshold. - Minimum length = 1 + Minimum length = 1 + + .PARAMETER RedirectPortRewrite + Rewrite the port and change the protocol to ensure successful HTTP redirects from services. + Default value: DISABLED + Possible values = ENABLED, DISABLED .PARAMETER Passthru Return the load balancer server object. @@ -153,21 +158,21 @@ function New-NSLBVirtualServer { [parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [string[]]$Name = (Read-Host -Prompt 'LB virtual server name'), - + [Parameter(Mandatory = $true, ParameterSetName = "Addressable")] [ValidateScript({$_ -match [IPAddress]$_ })] [string]$IPAddress, - + [Parameter(Mandatory = $true, ParameterSetName = "NonAddressable")] [Switch]$NonAddressable, - + [Parameter(Mandatory = $true, ParameterSetName = "Addressable")] [ValidateRange(0, 65534)] [int]$Port = 80, - + [ValidateLength(0, 256)] [string]$Comment = '', - + [ValidateSet('DHCPRA','DIAMTER', 'DNS', 'DNS_TCP', 'DLTS', 'FTP', 'HTTP', 'MSSQL', 'MYSQL', 'NNTP', 'PUSH','RADIUS', 'RDP', 'RTSP', 'SIP_UDP', 'SSL', 'SSL_BRIDGE', 'SSL_DIAMETER', 'SSL_PUSH', 'SSL_TCP', 'TCP', 'TFTP', 'UDP')] [string]$ServiceType = 'HTTP', @@ -182,21 +187,25 @@ function New-NSLBVirtualServer { [Parameter()] [ValidateSet('PASSIVE', 'ACTIVE')] [string] - $ICMPVSRResponse = 'PASSIVE', + $ICMPVSRResponse = 'PASSIVE', [Parameter()] [string] $HTTPRedirectURL, [Parameter()] - [int]$TimeOut = 2, - + [int]$TimeOut = 2, + [Parameter()] - [int]$ClientTimeout, + [int]$ClientTimeout, [Parameter()] [string] - $BackupVServer, + $BackupVServer, + + [Parameter()] + [ValidateSet('ENABLED', 'DISABLED')] + [string]$RedirectPortRewrite = 'DISABLED', [Switch]$PassThru ) @@ -217,6 +226,7 @@ function New-NSLBVirtualServer { port = $Port lbmethod = $LBMethod icmpvsrresponse = $ICMPVSRResponse + redirectportrewrite = $RedirectPortRewrite } if ($PSBoundParameters.ContainsKey('PersistenceType')) { @@ -225,8 +235,8 @@ function New-NSLBVirtualServer { if ($PSBoundParameters.ContainsKey('RedirectFromPort')) { $params.Add('redirectfromport', $RedirectFromPort) } - if ($PSBoundParameters.ContainsKey('HTTPSRedirectURL')) { - $params.Add('rediurl', $HTTPSRedirectURL) + if ($PSBoundParameters.ContainsKey('HTTPRedirectURL')) { + $params.Add('redirurl', $HTTPRedirectURL) } if ($PSBoundParameters.ContainsKey('Timeout')) { $params.Add('timeout', $Timeout) @@ -234,9 +244,9 @@ function New-NSLBVirtualServer { if ($PSBoundParameters.ContainsKey('ClientTimeout')) { $params.Add('clttimeout', $ClientTimeout) } - if ($PSBoundParameters.ContainsKey('BackupVServer')) { + if (($PSBoundParameters.ContainsKey('BackupVServer')) -AND ($Port -eq 443) -AND ($ServiceType -eq 'ssl')) { $params.Add('backupvserver', $BackupVServer) - } + } _InvokeNSRestApi -Session $Session -Method POST -Type lbvserver -Payload $params -Action add if ($PSBoundParameters.ContainsKey('PassThru')) { diff --git a/NetScaler/Public/New-NSResponderAction.ps1 b/NetScaler/Public/New-NSResponderAction.ps1 index dec498a..725aa22 100644 --- a/NetScaler/Public/New-NSResponderAction.ps1 +++ b/NetScaler/Public/New-NSResponderAction.ps1 @@ -23,11 +23,14 @@ function New-NSResponderAction { Adds a responder action. .EXAMPLE - New-NSResponderAction -Name 'act-redirect' -Type Redirect ` - -Target '"https://" + HTTP.REQ.HOSTNAME.HTTP_URL_SAFE + "/test/"' -ResponseStatusCode 302 + New-NSResponderAction -Name 'act-redirect' -Type Redirect -Target '"https://" + HTTP.REQ.HOSTNAME.HTTP_URL_SAFE + "/test/"' -ResponseStatusCode 302 Creates a new responder action which redirects to /test + New-NSResponderAction -Name NewHTMLPage -Type RespondWithHTMLPage -HTMLPage "NewHTMLPage" + Creates a new responder action that uses a html page. Html pages are uploaded via the New-NSResponderHTMLPage function. The HTML page used in this example is just a label + + .PARAMETER Session The NetScaler session object. @@ -36,7 +39,7 @@ function New-NSResponderAction { .PARAMETER Type The type of responder action to create. - + Default value: NOOP Possible values = NOOP, Redirect, RespondWith, RespondWithSQLOK, RespondWithSQLError, RespondWithHTMLPage @@ -47,7 +50,7 @@ function New-NSResponderAction { .PARAMETER ResponseStatusCode The HTTP response status code returned by the responder action. Valid only for types Redirect, RespondWith, RespondWithSQLOK and RespondWithSQLError. - + Range: 100 - 599 .PARAMETER ReasonPhrase @@ -59,9 +62,9 @@ function New-NSResponderAction { .PARAMETER HtmlPage The name of the HTML page to respond with. - + Valid only for type RespondWithHTMLPage. - + .PARAMETER Comment Any information about the responder action. @@ -78,7 +81,7 @@ function New-NSResponderAction { [parameter(Mandatory, ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName = $true)] [string[]]$Name, - [ValidateSet('NOOP','Redirect','RespondWith', 'RespondWithSQLOK','RespondWithSQLError','RespondWithHTMLPage')] + [ValidateSet('NOOP','Redirect','RespondWith', 'RespondWithSQLOK','RespondWithSQLError','RespondWithHTMLPage')] [string]$Type = 'NOOP', [ValidateLength(0, 8191)] @@ -91,9 +94,12 @@ function New-NSResponderAction { [ValidateLength(0, 8191)] [string]$ReasonPhrase = [string]::Empty, + [ValidateLength(0, 8191)] + [string]$HTMLPage = [string]::Empty, + [ValidateLength(0, 256)] [string]$Comment = [string]::Empty, - + [Switch]$PassThru ) @@ -113,7 +119,7 @@ function New-NSResponderAction { default { $Type.ToLower() } } ) - + $params = @{ name = $Item type = $NitroType @@ -124,8 +130,8 @@ function New-NSResponderAction { if ($PSBoundParameters.ContainsKey('Target')) { $params.Add('target', $Target) } else { - throw "Target is mandatory if type is NOOP, Redirect or RespondWith" - } + throw "Target is mandatory if type is NOOP, Redirect or RespondWith" + } } "^(redirect|sqlresponse_ok|sqlresponse_error|respondwithhtmlpage)$" { if ($PSBoundParameters.ContainsKey('ResponseStatusCode')) { @@ -133,7 +139,7 @@ function New-NSResponderAction { } if ($PSBoundParameters.ContainsKey('ReasonPhrase')) { $params.Add('reasonphrase', $ReasonPhrase) - } + } } "respondwithhtmlpage" { if ($PSBoundParameters.ContainsKey('HtmlPage')) { diff --git a/NetScaler/Public/New-NSResponderHTMLPage.ps1 b/NetScaler/Public/New-NSResponderHTMLPage.ps1 index db02428..5b7c219 100644 --- a/NetScaler/Public/New-NSResponderHTMLPage.ps1 +++ b/NetScaler/Public/New-NSResponderHTMLPage.ps1 @@ -17,20 +17,15 @@ limitations under the License. function New-NSResponderHTMLPage { <# .SYNOPSIS - Add server certificate to NetScaler appliance. + Add Responder HTML page to NetScaler appliance. .DESCRIPTION - Add server certificate to NetScaler appliance. + Add Responder HTML page to NetScaler appliance. .EXAMPLE - Add-NSCertKeyPair -CertKeyName 'myrootCA' -CertPath '/nsconfig/ssl/mycertificate.cert' -CertKeyFormat 'PEM' + New-NSResponderHTMLPage -Name 'myrootCA' -Source 'http://somewebsite.com/somefile' -Comment 'Application XYZ page' - Creates a root certificate key pair named 'myrootCA' using the PEM formatted certificate 'mycertificate.cert' located on the appliance. - - .EXAMPLE - Add-NSCertKeyPair -CertKeyName 'mywildcardcert' -CertPath '/nsconfig/ssl/mywildcard.cert' -KeyPath '/nsconfig/ssl/mywildcard.key' -CertKeyFormat 'PEM' - - Creates a certificate key pair named 'mywildardcert' using the PEM formatted certificate 'mywildcard.cert' and 'mywildcard.key' key file located on the appliance. + Creates a Responder HTML page sourcing from a repo named 'http://somewebsite.com/somefile' into the appliance. .PARAMETER Session The NetScaler session object. @@ -39,9 +34,9 @@ function New-NSResponderHTMLPage { Name to assign to the HTML page object on the NetScaler appliance. Minimum length = 1 Maximum length = 31 - + .PARAMETER Source - Local path to and name of, or URL \(protocol, host, path, and file name\) for, the file in which to store the imported HTML page. NOTE: The import fails if the object to be imported is on an HTTPS server that requires client certificate authentication for access. + Local path to and name of, or URL \(protocol, host, path, and file name\) for, the file in which to store the imported HTML page. NOTE: The import fails if the object to be imported is on an HTTPS server that requires client certificate authentication for access. Also, check any firewall rules in between source and destination. Minimum length = 1 Maximum length = 2047 @@ -63,9 +58,6 @@ function New-NSResponderHTMLPage { [Parameter()] [string]$Source, - [Parameter()] - [string]$Comment, - [Parameter()] [switch]$Overwrite = $false ) @@ -80,7 +72,6 @@ function New-NSResponderHTMLPage { $params = @{ src = $Source name = $Name - comment = $Comment overwrite = $Overwrite.ToBool() } $response = _InvokeNSRestApi -Session $Session -Method POST -Type responderhtmlpage -Payload $params -Action import diff --git a/NetScaler/Public/New-NSResponderPolicy.ps1 b/NetScaler/Public/New-NSResponderPolicy.ps1 index 5ffb368..60d0b7a 100644 --- a/NetScaler/Public/New-NSResponderPolicy.ps1 +++ b/NetScaler/Public/New-NSResponderPolicy.ps1 @@ -42,6 +42,9 @@ function New-NSResponderPolicy { * RESET - Reset the client connection by closing it. The client program, such as a browser, will handle this and may inform the user. The client may then resend the request if desired. * DROP - Drop the request without sending a response to the user. + .PARAMETER UndefinedAction + Action to perform if the result of policy evaluation is undefined (UNDEF). An UNDEF event indicates an internal error condition. Only the above built-in actions can be used + .PARAMETER Comment Adds a comment to the Responder Policy. @@ -61,6 +64,10 @@ function New-NSResponderPolicy { [Parameter(Mandatory=$True)] [string]$Action, + [Parameter()] + [ValidateSet('NOOP','RESET','DROP')] + [string]$UndefinedAction = '', + [Parameter()] [string]$Comment, @@ -79,6 +86,8 @@ function New-NSResponderPolicy { name = $Item rule = $Rule action = $Action + comment = $Comment + undefaction = $UndefinedAction } _InvokeNSRestApi -Session $Session -Method POST -Type responderpolicy -Payload $params -Action add diff --git a/NetScaler/Public/New-NSSSLProfile.ps1 b/NetScaler/Public/New-NSSSLProfile.ps1 index 9ae92b4..1f1b3a7 100644 --- a/NetScaler/Public/New-NSSSLProfile.ps1 +++ b/NetScaler/Public/New-NSSSLProfile.ps1 @@ -76,9 +76,13 @@ function New-NSSSLProfile { .PARAMETER ProfileType Type of profile. Front end profiles apply to the entity that receives requests from a client. Backend profiles apply to the entity that sends client requests to a server. - Default value: FrontEnd + .PARAMETER DenySslRenegotiation + Deny renegotiation in specified circumstances. Available settings function as follows: * NO - Allow SSL renegotiation. * FRONTEND_CLIENT - Deny secure and nonsecure SSL renegotiation initiated by the client. * FRONTEND_CLIENTSERVER - Deny secure and nonsecure SSL renegotiation initiated by the client or the NetScaler during policy-based client authentication. * ALL - Deny all secure and nonsecure SSL renegotiation. * NONSECURE - Deny nonsecure SSL renegotiation. Allows only clients that support RFC 5746. + Default value: ALL + Possible values = NO, FRONTEND_CLIENT, FRONTEND_CLIENTSERVER, ALL, NONSECURE + .EXAMPLE New-NSSSLProfile -Name "Secure_SSL_Profile" -ProfileType "FrontEnd" -SSL3 $false -TLS1 $true -TLS11 $true -TLS12 $true -DenySslRenegotiation "FRONTEND_CLIENT" diff --git a/NetScaler/Public/Remove-NSCertFile.ps1 b/NetScaler/Public/Remove-NSCertFile.ps1 new file mode 100644 index 0000000..b99ac07 --- /dev/null +++ b/NetScaler/Public/Remove-NSCertFile.ps1 @@ -0,0 +1,70 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Remove-NSCertFile { + <# + .SYNOPSIS + Add server certificate to NetScaler appliance. + + .DESCRIPTION + Add server certificate to NetScaler appliance. + + .EXAMPLE + Add-NSCertKeyPair -CertKeyName 'myrootCA' -CertPath '/nsconfig/ssl/mycertificate.cert' -CertKeyFormat 'PEM' + + Creates a root certificate key pair named 'myrootCA' using the PEM formatted certificate 'mycertificate.cert' located on the appliance. + + .EXAMPLE + Add-NSCertKeyPair -CertKeyName 'mywildcardcert' -CertPath '/nsconfig/ssl/mywildcard.cert' -KeyPath '/nsconfig/ssl/mywildcard.key' -CertKeyFormat 'PEM' + + Creates a certificate key pair named 'mywildardcert' using the PEM formatted certificate 'mywildcard.cert' and 'mywildcard.key' key file located on the appliance. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER CertName + Name to assign to the imported certificate file. Must begin with an ASCII alphanumeric or underscore (_) character, and must contain only ASCII alphanumeric, underscore, hash (#), period (.), space, colon (:), at (@), equals (=), and hyphen (-) characters. The following requirement applies only to the NetScaler CLI: If the name includes one or more spaces, enclose the name in double or single quotation marks (for example, "my file" or 'my file'). + Minimum length = 1 + Maximum length = 31 + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [Parameter()] + [string[]]$CertName + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $CertName) { + if ($PSCmdlet.ShouldProcess($item, 'Remove imported certificate')) { + try { + $params = @{ + name = $CertName + } + _InvokeNSRestApi -Session $Session -Method DELETE -Type sslcertfile -Resource $item -Arguments $params -Action delete + + } catch { + throw $_ + } + } + } + } +} diff --git a/NetScaler/Public/Remove-NSDnsNameServer.ps1 b/NetScaler/Public/Remove-NSDnsNameServer.ps1 index 522a8d3..bcc3966 100644 --- a/NetScaler/Public/Remove-NSDnsNameServer.ps1 +++ b/NetScaler/Public/Remove-NSDnsNameServer.ps1 @@ -1,5 +1,5 @@ <# -Copyright 2017 Juan C. Herrera +Copyright 2015 Brandon Olin Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,20 +17,20 @@ limitations under the License. function Remove-NSDnsNameServer { <# .SYNOPSIS - Removes a domain name server from NetScaler appliance. + Add domain name server to NetScaler appliance. .DESCRIPTION - Remove a domain name server from NetScaler appliance. + Add domain name server to NetScaler appliance. .EXAMPLE - Remove-NSDnsNameServer -IPAddress '8.8.8.8' + Add-NSDnsNameServer -DNSServerIP '8.8.8.8' - Remove DNS server IP 8.8.8.8 from NetScaler. + Adds DNS server IP 8.8.8.8 to NetScaler. .EXAMPLE - '2.2.2.2', '8.8.8.8' | Remove-NSDnsNameServer -Session $session + '2.2.2.2', '8.8.8.8' | Add-NSDnsNameServer -Session $session - Removes DNS servers with IPs 2.2.2.2 and 8.8.8.8 from NetScaler using the pipeline. + Adds DNS server IP 8.8.8.8 to NetScaler using the pipeline. .PARAMETER Session The NetScaler session object. @@ -38,6 +38,30 @@ function Remove-NSDnsNameServer { .PARAMETER IPAddress IP address of an external name server or, if the Local parameter is set, IP address of a local DNS server (LDNS). + .PARAMETER DNSVServerName + Name of a DNS virtual server. Overrides any IP address-based name servers configured on the NetScaler appliance. + + .PARAMETER Local + Mark the IP address as one that belongs to a local recursive DNS server on the NetScaler appliance. + The appliance recursively resolves queries received on an IP address that is marked as being local. + For recursive resolution to work, the global DNS parameter, Recursion, must also be set. + If no name server is marked as being local, the appliance functions as a stub resolver and load balances the name servers. + + .PARAMETER State + Administrative state of the name server. + + Default value: ENABLED + Possible values = ENABLED, DISABLED + + .PARAMETER Type + Protocol used by the name server. UDP_TCP is not valid if the name server is a DNS virtual server configured on the appliance. + + Default value: UDP + Possible values = UDP, TCP, UDP_TCP + + .PARAMETER Passthru + Return the load balancer server object. + .PARAMETER Force Suppress confirmation adding certificate binding #> @@ -46,10 +70,11 @@ function Remove-NSDnsNameServer { $Session = $script:session, [parameter()] - # [ValidateScript({$_ -match [IPAddress]$_ })] + [ValidateScript({$_ -match [IPAddress]$_ })] [string[]]$IPAddress = (Read-Host -Prompt 'DNS server IP'), - [Switch]$Force + [string]$DNSVServerName = [string]::Empty + ) begin { @@ -58,10 +83,17 @@ function Remove-NSDnsNameServer { process { foreach ($item in $IPAddress) { - if ($Force -or $PSCmdlet.ShouldProcess($item, 'Remove DNS server IP')) { + if ($PSCmdlet.ShouldProcess($item, 'Add DNS server IP')) { try { - _InvokeNSRestApi -Session $Session -Method DELETE -Type dnsnameserver -Resource $item -Action delete + $params = @{ + ip = $IPAddress + } + if ($PSBoundParameters.ContainsKey('DNSVServerName')) { + $params.Add('dnsvservername', $DNSVServerName) + } + + $response = _InvokeNSRestApi -Session $Session -Method DELETE -Type dnsnameserver -Payload $params -Action delete } catch { throw $_ @@ -69,4 +101,4 @@ function Remove-NSDnsNameServer { } } } -} +} \ No newline at end of file diff --git a/NetScaler/Public/Remove-NSLBSSLCipherGroupBinding.ps1 b/NetScaler/Public/Remove-NSLBSSLCipherGroupBinding.ps1 new file mode 100644 index 0000000..3967e07 --- /dev/null +++ b/NetScaler/Public/Remove-NSLBSSLCipherGroupBinding.ps1 @@ -0,0 +1,83 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Remove-NSLBSSLCipherGroupBinding { + <# + .SYNOPSIS + Removes a new load balancer cipher group binding. + + .DESCRIPTION + Removes a new load balancer cipher group binding. + + .EXAMPLE + Remove-NSLBSSLCipherBinding -VirtualServerName 'vserver01' -Ciphername 'somecipher' + + Removes the SSL cipher group 'somecipher' from the virtual server 'vserver01'. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VirtualServerName + Name of the SSL virtual server + + .PARAMETER CipherName + Name of the individual cipher, user-defined cipher group, or predefined (built-in) cipher alias. + + .PARAMETER Passthru + Return the load balancer server object. + + .PARAMETER Force + Suppress confirmation adding certificate binding. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Medium', DefaultParameterSetName='servicegroup')] + param( + $Session = $script:session, + + [parameter(Mandatory=$True)] + [string]$VirtualServerName = (Read-Host -Prompt 'LB virtual server name'), + + [parameter(Mandatory=$True)] + [string]$CipherName, + + [Switch]$PassThru, + + [switch]$Force + ) + + begin { + _AssertSessionActive + } + + process { + if ($Force -or $PSCmdlet.ShouldProcess($VirtualServerName, 'Removes Cipher Suite Binding')) { + try { + + $params = @{ + vservername = $VirtualServerName + ciphername = $CipherName + } + + _InvokeNSRestApi -Session $Session -Method DELETE -Type sslvserver_sslcipher_binding -Resource $VirtualServerName -Arguments $params -Action delete + + if ($PSBoundParameters.ContainsKey('PassThru')) { + return Get-NSLBSSLCipherGroupBinding -Session $Session -VirtualServerName $VirtualServerName + } + } catch { + throw $_ + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Remove-NSLBSSLCipherSuiteBinding.ps1 b/NetScaler/Public/Remove-NSLBSSLCipherSuiteBinding.ps1 new file mode 100644 index 0000000..356119c --- /dev/null +++ b/NetScaler/Public/Remove-NSLBSSLCipherSuiteBinding.ps1 @@ -0,0 +1,83 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Remove-NSLBSSLCipherSuiteBinding { + <# + .SYNOPSIS + Adds a new load balancer server certificate binding. + + .DESCRIPTION + Adds a new load balancer server certificate binding. + + .EXAMPLE + Add-NSLBSSLVirtualServerCertificateBinding -VirtualServerName 'vserver01' -Certificate 'cert' + + Bind the SSL certificate 'cert' to virtual server 'vserver01'. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VirtualServerName + Name of the SSL virtual server + + .PARAMETER Certificate + The name of the certificate key pair binding. + + .PARAMETER Passthru + Return the load balancer server object. + + .PARAMETER Force + Suppress confirmation adding certificate binding. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Medium', DefaultParameterSetName='servicegroup')] + param( + $Session = $script:session, + + [parameter(Mandatory=$True)] + [string]$VirtualServerName = (Read-Host -Prompt 'LB virtual server name'), + + [parameter(Mandatory=$True)] + [string]$CipherName, + + [Switch]$PassThru, + + [switch]$Force + ) + + begin { + _AssertSessionActive + } + + process { + if ($Force -or $PSCmdlet.ShouldProcess($VirtualServerName, 'Removes Cipher Suite Binding')) { + try { + + $params = @{ + vservername = $VirtualServerName + ciphername = $CipherName + } + + _InvokeNSRestApi -Session $Session -Method DELETE -Type sslvserver_sslciphersuite_binding -Resource $VirtualServerName -Arguments $params -Action delete + + if ($PSBoundParameters.ContainsKey('PassThru')) { + return Get-NSLBSSLCipherSuiteBinding -Session $Session -VirtualServerName $VirtualServerName + } + } catch { + throw $_ + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Remove-NSLBSSLVirtualServerCertificateBinding.ps1 b/NetScaler/Public/Remove-NSLBSSLVirtualServerCertificateBinding.ps1 new file mode 100644 index 0000000..1d754d6 --- /dev/null +++ b/NetScaler/Public/Remove-NSLBSSLVirtualServerCertificateBinding.ps1 @@ -0,0 +1,83 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Remove-NSLBSSLVirtualServerCertificateBinding { + <# + .SYNOPSIS + Adds a new load balancer server certificate binding. + + .DESCRIPTION + Adds a new load balancer server certificate binding. + + .EXAMPLE + Add-NSLBSSLVirtualServerCertificateBinding -VirtualServerName 'vserver01' -Certificate 'cert' + + Bind the SSL certificate 'cert' to virtual server 'vserver01'. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VirtualServerName + Name of the SSL virtual server + + .PARAMETER Certificate + The name of the certificate key pair binding. + + .PARAMETER Passthru + Return the load balancer server object. + + .PARAMETER Force + Suppress confirmation adding certificate binding. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Medium', DefaultParameterSetName='servicegroup')] + param( + $Session = $script:session, + + [parameter(Mandatory=$True)] + [string]$VirtualServerName = (Read-Host -Prompt 'LB virtual server name'), + + [parameter(Mandatory=$True)] + [string]$Certificate, + + [Switch]$PassThru, + + [switch]$Force + ) + + begin { + _AssertSessionActive + } + + process { + if ($Force -or $PSCmdlet.ShouldProcess($VirtualServerName, 'Remove Virtual Server Binding')) { + try { + + $params = @{ + vservername = $VirtualServerName + certkeyname = $Certificate + } + + _InvokeNSRestApi -Session $Session -Method DELETE -Type sslvserver_sslcertkey_binding -Resource $VirtualServerName -Arguments $params -Action delete + + if ($PSBoundParameters.ContainsKey('PassThru')) { + return Get-NSLBSSLVirtualServerCertificateBinding -Session $Session -VirtualServerName $VirtualServerName + } + } catch { + throw $_ + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Remove-NSLBServiceGroupMemberBinding.ps1 b/NetScaler/Public/Remove-NSLBServiceGroupMemberBinding.ps1 index d0dd893..73192ed 100644 --- a/NetScaler/Public/Remove-NSLBServiceGroupMemberBinding.ps1 +++ b/NetScaler/Public/Remove-NSLBServiceGroupMemberBinding.ps1 @@ -29,7 +29,7 @@ function Remove-NSLBServiceGroupMemberBinding { .EXAMPLE $x = Remove-NSLBServiceGroupMember -Name 'sg01' -ServerName 'server01' -Port 80 -PassThru - + Disassociates server 'server01' with service group 'sg01' and return the object. .PARAMETER Session @@ -42,7 +42,7 @@ function Remove-NSLBServiceGroupMemberBinding { Name of the server to which to bind the service group. .PARAMETER IPAddress - IP Address of the server/resource. + IP Address of the server/resource. .PARAMETER Port Server port number. @@ -57,7 +57,7 @@ function Remove-NSLBServiceGroupMemberBinding { $Session = $script:session, [parameter(Mandatory, ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName = $true)] - [string[]]$Name, + [string[]]$ServiceName, [Parameter(Mandatory)] [string[]]$ServerName, @@ -66,10 +66,6 @@ function Remove-NSLBServiceGroupMemberBinding { [ValidateRange(1, 65535)] [int]$Port, - [parameter()] - [ValidateScript({$_ -match [IPAddress]$_ })] - [string]$IPAddress, - [switch]$PassThru ) @@ -78,7 +74,7 @@ function Remove-NSLBServiceGroupMemberBinding { } process { - foreach ($item in $Name) { + foreach ($item in $ServiceName) { foreach ($member in $ServerName) { if ($PSCmdlet.ShouldProcess($item, "Remove Service Group Member: $Member")) { try { @@ -86,10 +82,7 @@ function Remove-NSLBServiceGroupMemberBinding { servicegroupname = $item servername = $ServerName port = $Port - } - if ($PSBoundParameters.ContainsKey('ip')) { - $params.ip = $IPAddress - } + } _InvokeNSRestApi -Session $Session -Method DELETE -Type servicegroup_servicegroupmember_binding -Resource $item -Arguments $params -Action delete diff --git a/NetScaler/Public/Remove-NSLBServiceMonitorBinding.ps1 b/NetScaler/Public/Remove-NSLBServiceMonitorBinding.ps1 new file mode 100644 index 0000000..f52a0ca --- /dev/null +++ b/NetScaler/Public/Remove-NSLBServiceMonitorBinding.ps1 @@ -0,0 +1,74 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Remove-NSLBServiceMonitorBinding { + <# + .SYNOPSIS + Removes a monitor binding from a service. + + .DESCRIPTION + Removes a monitor binding from a service. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER ServiceName + The name of the service to unbind the monitor. + + .PARAMETER MonitorName + The name of the monitor to unbind. + + .EXAMPLE + Remove-NSLBServiceMonitorBinding -ServiceName 'svc01' -MonitorName 'mon01' + + Unbinds the monitor named 'mon01' from the service group 'svc01'. + + .PARAMETER Force + Suppress confirmation when removing a responder action. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] + param( + $Session = $script:session, + + [parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [string[]]$ServiceName, + + [parameter(Mandatory = $true, ValueFromPipeline = $true)] + [string]$MonitorName, + + [switch]$Force + ) + + begin { + _AssertSessionActive + } + + process { + + $params =@{ + monitor_name = $MonitorName + } + foreach ($item in $ServiceName) { + if ($Force -or $PSCmdlet.ShouldProcess($item, 'Delete Monitor Binding')) { + try { + _InvokeNSRestApi -Session $Session -Method DELETE -Type service_lbmonitor_binding -Resource $item -Arguments $params -Action delete + } catch { + throw $_ + } + } + } + } +} diff --git a/NetScaler/Public/Remove-NSResponderHTMLPage.ps1 b/NetScaler/Public/Remove-NSResponderHTMLPage.ps1 new file mode 100644 index 0000000..28e0bfb --- /dev/null +++ b/NetScaler/Public/Remove-NSResponderHTMLPage.ps1 @@ -0,0 +1,63 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Remove-NSResponderHTMLPage { + <# + .SYNOPSIS + Removes a responder HTML page from the NetScaler appliance. + + .DESCRIPTION + Removes a responder HTML page from the NetScaler appliance. + + .EXAMPLE + Remove-NSResponderHTMLPage -Name 'myHTMLpage' + + Removes a Responder Policy HTML page from the appliance. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER Name + Name to assign to the HTML page object on the NetScaler appliance. + Minimum length = 1 + Maximum length = 31 + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [Parameter()] + [string]$Name, + + [switch]$Force + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $Name) { + if ($Force -or $PSCmdlet.ShouldProcess($item, 'Delete ResponderHTML Page')) { + try { + _InvokeNSRestApi -Session $Session -Method DELETE -Type responderhtmlpage -Resource $item -Action DELETE + } catch { + throw $_ + } + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Remove-NSVLANInterfaceBinding.ps1 b/NetScaler/Public/Remove-NSVLANInterfaceBinding.ps1 index 67c6e74..751706d 100644 --- a/NetScaler/Public/Remove-NSVLANInterfaceBinding.ps1 +++ b/NetScaler/Public/Remove-NSVLANInterfaceBinding.ps1 @@ -17,15 +17,15 @@ limitations under the License. function Remove-NSVLANInterfaceBinding { <# .SYNOPSIS - Deletes the binding of an interface as well as untagged/unbound from NetScaler appliance. + Removes the binding of an interface as well as untagged/unbound from NetScaler appliance. .DESCRIPTION - Deletes the binding of an interface as well as untagged/unbound from NetScaler appliance. + Removes the binding of an interface as well as untagged/unbound from NetScaler appliance. .EXAMPLE - Remove-NSVLANBinding -VLANID 150 -AliasName 'testvlan' -MTU 1500 + Remove-NSVLANInterfaceBinding -VLANID 150 -interface '0/1' -tagged - Adds VLAN 150 with an alias name of 'testvlan' and MTU of 1500 to the NetScaler appliance. + Adds binding for interface '0/1' and tags the vlan on the NetScaler appliance. .PARAMETER Session The NetScaler session object. @@ -37,7 +37,7 @@ function Remove-NSVLANInterfaceBinding { The interface to be bound to the VLAN, specified in slot/port notation (for example, 1/3). .PARAMETER Tagged - Make the interface an 802.1q tagged interface. + Make the interface an 802.1q tagged interface. #> [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')] param ( @@ -47,10 +47,7 @@ function Remove-NSVLANInterfaceBinding { [string[]]$VLANID, [parameter()] - [string[]]$Interface, - - # [parameter()] - # [switch]$Tagged, + [string[]]$Interface = '0/1', [Switch]$Force @@ -63,11 +60,12 @@ function Remove-NSVLANInterfaceBinding { process { $params = @{ + id = $VLANID ifnum = $Interface - #tagged = $Tagged.ToBool() not working - - } + } + foreach ($item in $VLANID) { - if ($Force -or $PSCmdlet.ShouldProcess($item, 'Remove VLAN binding')) { + if ($Force -or $PSCmdlet.ShouldProcess($item, 'Remove VLAN interaface binding')) { try { _InvokeNSRestApi -Session $Session -Method DELETE -Type vlan_interface_binding -Resource $item -Arguments $params -Action delete } diff --git a/NetScaler/Public/Set-NSLBVirtualServer.ps1 b/NetScaler/Public/Set-NSLBVirtualServer.ps1 index af10f88..06f0628 100644 --- a/NetScaler/Public/Set-NSLBVirtualServer.ps1 +++ b/NetScaler/Public/Set-NSLBVirtualServer.ps1 @@ -73,6 +73,11 @@ function Set-NSLBVirtualServer { Name of the backup virtual server to which to forward requests if the primary virtual server goes DOWN or reaches its spillover threshold. Minimum length = 1 + .PARAMETER RedirectPortRewrite + Rewrite the port and change the protocol to ensure successful HTTP redirects from services. + Default value: DISABLED + Possible values = ENABLED, DISABLED + .PARAMETER Force Suppress confirmation when updating a virtual server. @@ -119,6 +124,10 @@ function Set-NSLBVirtualServer { [string] $BackupVServer, + [Parameter()] + [ValidateSet('ENABLED', 'DISABLED')] + [string]$RedirectPortRewrite = 'DISABLED', + [Switch]$Force, [Switch]$PassThru @@ -154,11 +163,12 @@ function Set-NSLBVirtualServer { if ($PSBoundParameters.ContainsKey('ClientTimeout')) { $params.Add('clttimeout', $ClientTimeout) } - if ($PSBoundParameters.ContainsKey('BackupVServer')) { $params.Add('backupvserver', $BackupVServer) } - + if ($PSBoundParameters.ContainsKey('RedirectPortRewrite')) { + $params.Add('RedirectPortRewrite', $RedirectPortRewrite) + } _InvokeNSRestApi -Session $Session -Method PUT -Type lbvserver -Payload $params -Action update if ($PSBoundParameters.ContainsKey('PassThru')) { diff --git a/NetScaler/Public/Set-NSResponderAction.ps1 b/NetScaler/Public/Set-NSResponderAction.ps1 index 21060de..9afb580 100644 --- a/NetScaler/Public/Set-NSResponderAction.ps1 +++ b/NetScaler/Public/Set-NSResponderAction.ps1 @@ -89,6 +89,9 @@ function Set-NSResponderAction { [ValidateLength(0, 256)] [string]$Comment = [string]::Empty, + [ValidateLength(0, 256)] + [string]$HtmlPage = [string]::Empty, + [switch]$Force, [switch]$PassThru diff --git a/NetScaler/Public/Set-NSResponderPolicy.ps1 b/NetScaler/Public/Set-NSResponderPolicy.ps1 index 2c6b616..a78d7ef 100644 --- a/NetScaler/Public/Set-NSResponderPolicy.ps1 +++ b/NetScaler/Public/Set-NSResponderPolicy.ps1 @@ -42,6 +42,9 @@ function Set-NSResponderPolicy { * RESET - Reset the client connection by closing it. The client program, such as a browser, will handle this and may inform the user. The client may then resend the request if desired. * DROP - Drop the request without sending a response to the user. + .PARAMETER UndefinedAction + Action to perform if the result of policy evaluation is undefined (UNDEF). An UNDEF event indicates an internal error condition. Only the above built-in actions can be used + .PARAMETER Passthru Return the responder policy. #> @@ -53,12 +56,14 @@ function Set-NSResponderPolicy { [string[]]$Name, [Parameter()] - [string] - $Rule, + [string]$Rule, + + [Parameter()] + [string]$Action, [Parameter()] - [string] - $Action, + [ValidateSet('NOOP','RESET','DROP')] + [string]$UndefinedAction = '', [Parameter()] [string]$Comment, @@ -79,6 +84,7 @@ function Set-NSResponderPolicy { rule = $Rule action = $Action comment = $Comment + undefaction = $UndefinedAction } _InvokeNSRestApi -Session $Session -Method PUT -Type responderpolicy -Payload $params -Action update diff --git a/NetScaler/Public/Set-NSVLANInterfaceBinding.ps1 b/NetScaler/Public/Set-NSVLANInterfaceBinding.ps1 new file mode 100644 index 0000000..52e3ea4 --- /dev/null +++ b/NetScaler/Public/Set-NSVLANInterfaceBinding.ps1 @@ -0,0 +1,82 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Set-NSVLANInterfaceBinding { + <# + .SYNOPSIS + Binds a VLAN to an interface and tags/untags to NetScaler appliance. + + .DESCRIPTION + Binds a VLAN to an interface and tags/untags to NetScaler appliance. + + .EXAMPLE + Set-NSVLANInterfaceBinding -VLANID 150 -Interface '0/1' -Tagged + + Binds VLAN 150 to interface '0/1' and tags it on the NetScaler appliance. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VLANID + A positive integer that uniquely identifies a VLAN. + + .PARAMETER Interface + The interface to be bound to the VLAN, specified in slot/port notation (for example, 1/3). + + .PARAMETER Tagged + Make the interface an 802.1q tagged interface. + + .PARAMETER Force + Suppress confirmation when adding a DNS suffix. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')] + param ( + $Session = $script:session, + + [parameter(Mandatory, ValueFromPipeline)] + [string[]]$VLANID, + + [parameter(Mandatory, ValueFromPipeline)] + [string[]]$Interface, + + [parameter()] + [switch]$Tagged, + + [switch]$Force + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $VLANID) { + if ($PSCmdlet.ShouldProcess($item, 'Add VLAN Binding')) { + try { + $params = @{ + id = $item + ifnum = $Interface + tagged = $Tagged.ToBool() + } + $response = _InvokeNSRestApi -Session $Session -Method PUT -Type vlan_interface_binding -Payload $params -Action add + } + catch { + throw $_ + } + } + } + } +} From 7861720f1da96d28200064ad56ffc004c193524b Mon Sep 17 00:00:00 2001 From: Herrera Date: Mon, 13 Nov 2017 15:38:25 -0800 Subject: [PATCH 5/7] revised some functions, added new functionality --- NetScaler/NetScaler.psd1 | 17 +++-- .../Add-NSLBSSLProfileToVserverBinding.ps1 | 72 +++++++++++++++++++ ...SLBSSLVirtualServerCipherGroupBinding.ps1} | 8 +-- ...SLBSSLVirtualServerCipherSuiteBinding.ps1} | 6 +- .../Get-NSLBSSLProfileToVserverBinding.ps1 | 62 ++++++++++++++++ ...SLBSSLVirtualServerCipherGroupBinding.ps1} | 6 +- ...SLBSSLVirtualServerCipherSuiteBinding.ps1} | 6 +- NetScaler/Public/Get-NSResponderHTMLPage.ps1 | 2 +- NetScaler/Public/New-NSLBServiceGroup.ps1 | 30 ++++---- NetScaler/Public/New-NSSSLProfile.ps1 | 6 -- .../Remove-NSLBSSLProfileToVserverBinding.ps1 | 67 +++++++++++++++++ ...NSLBSSLVirtualServerCertificateBinding.ps1 | 8 +-- ...SLBSSLVirtualServerCipherGroupBinding.ps1} | 12 ++-- ...SLBSSLVirtualServerCipherSuiteBinding.ps1} | 16 ++--- NetScaler/Public/Remove-NSVLAN.ps1 | 6 +- .../Public/Remove-NSVLANInterfaceBinding.ps1 | 6 +- NetScaler/Public/Set-NSLBMonitor.ps1 | 10 +-- NetScaler/Public/Set-NSLBServiceGroup.ps1 | 14 ++-- NetScaler/Public/Set-NSNTPServer.ps1 | 2 +- 19 files changed, 275 insertions(+), 81 deletions(-) create mode 100644 NetScaler/Public/Add-NSLBSSLProfileToVserverBinding.ps1 rename NetScaler/Public/{Add-NSLBSSLCipherGroupBinding.ps1 => Add-NSLBSSLVirtualServerCipherGroupBinding.ps1} (86%) rename NetScaler/Public/{Add-NSLBSSLCipherSuiteBinding.ps1 => Add-NSLBSSLVirtualServerCipherSuiteBinding.ps1} (88%) create mode 100644 NetScaler/Public/Get-NSLBSSLProfileToVserverBinding.ps1 rename NetScaler/Public/{Get-NSLBSSLCipherGroupBinding.ps1 => Get-NSLBSSLVirtualServerCipherGroupBinding.ps1} (91%) rename NetScaler/Public/{Get-NSLBSSLCipherSuiteBinding.ps1 => Get-NSLBSSLVirtualServerCipherSuiteBinding.ps1} (91%) create mode 100644 NetScaler/Public/Remove-NSLBSSLProfileToVserverBinding.ps1 rename NetScaler/Public/{Remove-NSLBSSLCipherGroupBinding.ps1 => Remove-NSLBSSLVirtualServerCipherGroupBinding.ps1} (81%) rename NetScaler/Public/{Remove-NSLBSSLCipherSuiteBinding.ps1 => Remove-NSLBSSLVirtualServerCipherSuiteBinding.ps1} (78%) diff --git a/NetScaler/NetScaler.psd1 b/NetScaler/NetScaler.psd1 index 56f0720..a95074a 100644 --- a/NetScaler/NetScaler.psd1 +++ b/NetScaler/NetScaler.psd1 @@ -75,9 +75,10 @@ FunctionsToExport = @( 'Add-NSLBServiceGroupMemberBinding', 'Add-NSLBServiceGroupMonitorBinding', 'Add-NSLBServiceMonitorBinding', - 'Add-NSLBSSLCipherGroupBinding', - 'Add-NSLBSSLCipherSuiteBinding', + 'Add-NSLBSSLProfileToVserverBinding', 'Add-NSLBSSLVirtualServerCertificateBinding', + 'Add-NSLBSSLVirtualServerCipherGroupBinding', + 'Add-NSLBSSLVirtualServerCipherSuiteBinding', 'Add-NSLBVirtualServerBinding', 'Add-NSCSVirtualServerPolicyBinding', 'Add-NSLBVirtualServerResponderPolicyBinding', @@ -132,9 +133,9 @@ FunctionsToExport = @( 'Get-NSLBServiceGroupMemberBinding', 'Get-NSLBServiceGroupMonitorBinding', 'Get-NSLBServiceMonitorBinding', - 'Get-NSLBSSLCipherGroupBinding', - 'Get-NSLBSSLCipherSuiteBinding', 'Get-NSLBSSLVirtualServer', + 'Get-NSLBSSLVirtualServerCipherGroupBinding', + 'Get-NSLBSSLVirtualServerCipherSuiteBinding', 'Get-NSLBSSLVirtualServerCertificateBinding', 'Get-NSLBSSLVirtualServerProfile', 'Get-NSLBStat', @@ -159,6 +160,7 @@ FunctionsToExport = @( 'Get-NSSSLCertificate', 'Get-NSSSLCertificateLink', 'Get-NSSSLProfile', + 'Get-NSLBSSLProfileToVserverBinding', 'Get-NSSystemFile', 'Get-NSTimeZone', 'Get-NSVersion', @@ -211,11 +213,11 @@ FunctionsToExport = @( 'Remove-NSLBServiceMonitorBinding', 'Remove-NSLBVirtualServer', 'Remove-NSLBVirtualServerBinding', - 'Remove-NSLBVirtualServerResponderPolicyBinding', - 'Remove-NSLBSSLCipherGroupBinding', - 'Remove-NSLBSSLCipherSuiteBinding', 'Remove-NSLBSSLVirtualServerCertificateBinding', + 'Remove-NSLBSSLVirtualServerCipherGroupBinding', + 'Remove-NSLBSSLVirtualServerCipherSuiteBinding', 'Remove-NSLBSSLVirtualServerProfile', + 'Remove-NSLBVirtualServerResponderPolicyBinding', 'Remove-NSLDAPAuthenticationPolicy', 'Remove-NSLDAPAuthenticationServer', 'Remove-NSNTPServer', @@ -226,6 +228,7 @@ FunctionsToExport = @( 'Remove-NSRewriteAction', 'Remove-NSSSLCertificateLink', 'Remove-NSSSLProfile', + 'Remove-NSLBSSLProfileToVserverBinding', 'Remove-NSSystemFile', 'Remove-NSVLAN', 'Remove-NSVLANInterfaceBinding', diff --git a/NetScaler/Public/Add-NSLBSSLProfileToVserverBinding.ps1 b/NetScaler/Public/Add-NSLBSSLProfileToVserverBinding.ps1 new file mode 100644 index 0000000..f6ae9c4 --- /dev/null +++ b/NetScaler/Public/Add-NSLBSSLProfileToVserverBinding.ps1 @@ -0,0 +1,72 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Add-NSLBSSLProfileToVserverBinding { + <# + .SYNOPSIS + Bind a ssl profile bound to a vserver + + .DESCRIPTION + Bind a ssl profile bound to a vserver + + .EXAMPLE + Add-NSLBSSLProfileToVserverBinding -VirtualServerName 'somevserver' -SSLProfile 'somesslprofile' + + Binds the ssl profile 'somesslprofile' to vserver 'somevserver' + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VirtualServerName + Name of the SSL virtual server for which to set advanced configuration. + + .PARAMETER SSLProfile + SSL profile associated to vserver. + Minimum length = 1 + Maximum length = 127 + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [Parameter(Mandatory)] + [string]$VirtualServerName, + + [Parameter(Mandatory)] + [ValidateLength(1,127)] + [string]$SSLProfile + ) + + begin { + _AssertSessionActive + } + + process { + if ($PSCmdlet.ShouldProcess($VirtualServerName, "Bind ssl profile $SSLProfile to virtualserver $VirtualServerName")) { + try { + $params = @{ + sslprofile = $SSLProfile + vservername = $VirtualServerName + } + $response = _InvokeNSRestApi -Session $Session -Method PUT -Type sslvserver -Payload $params -Action add + $response + } + catch { + throw $_ + } + } + } +} diff --git a/NetScaler/Public/Add-NSLBSSLCipherGroupBinding.ps1 b/NetScaler/Public/Add-NSLBSSLVirtualServerCipherGroupBinding.ps1 similarity index 86% rename from NetScaler/Public/Add-NSLBSSLCipherGroupBinding.ps1 rename to NetScaler/Public/Add-NSLBSSLVirtualServerCipherGroupBinding.ps1 index 14c387f..14290bb 100644 --- a/NetScaler/Public/Add-NSLBSSLCipherGroupBinding.ps1 +++ b/NetScaler/Public/Add-NSLBSSLVirtualServerCipherGroupBinding.ps1 @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. #> -function Add-NSLBSSLCipherGroupBinding { +function Add-NSLBSSLVirtualServerCipherGroupBinding { <# .SYNOPSIS Adds a new load balancer server to cipher group binding. @@ -23,7 +23,7 @@ function Add-NSLBSSLCipherGroupBinding { Adds a new load balancer server to cipher group binding. .EXAMPLE - Add-NSLBSSLCipherBinding -VirtualServerName 'vserver01' -CipherName 'somecipher' + Add-NSLBSSLVirtualServerCipherGroupBinding -VirtualServerName 'vserver01' -CipherName 'somecipher' Adds the binding of the SSL cipher group 'somecipher' to virtual server 'vserver01'. @@ -70,10 +70,10 @@ function Add-NSLBSSLCipherGroupBinding { ciphername = $CipherName } - _InvokeNSRestApi -Session $Session -Method PUT -Type sslvserver_sslcipher_binding -Payload $params + _InvokeNSRestApi -Session $Session -Method PUT -Type sslvserver_sslcipher_binding -Payload $params -action add if ($PSBoundParameters.ContainsKey('PassThru')) { - return Get-NSLBSSLCipherGroupBinding -Session $Session -VirtualServerName $VirtualServerName + return Get-NSLBSSLVirtualServerCipherGroupBinding -Session $Session -VirtualServerName $VirtualServerName } } catch { throw $_ diff --git a/NetScaler/Public/Add-NSLBSSLCipherSuiteBinding.ps1 b/NetScaler/Public/Add-NSLBSSLVirtualServerCipherSuiteBinding.ps1 similarity index 88% rename from NetScaler/Public/Add-NSLBSSLCipherSuiteBinding.ps1 rename to NetScaler/Public/Add-NSLBSSLVirtualServerCipherSuiteBinding.ps1 index f8dbfc6..6d385f5 100644 --- a/NetScaler/Public/Add-NSLBSSLCipherSuiteBinding.ps1 +++ b/NetScaler/Public/Add-NSLBSSLVirtualServerCipherSuiteBinding.ps1 @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. #> -function Add-NSLBSSLCipherSuiteBinding { +function Add-NSLBSSLVirtualServerCipherSuiteBinding { <# .SYNOPSIS Adds a new load balancer server to cipher suite binding. @@ -23,7 +23,7 @@ function Add-NSLBSSLCipherSuiteBinding { Adds a new load balancer server to cipher suite binding. .EXAMPLE - Add-NSLBSSLCipherSuiteBinding -VirtualServerName 'vserver01' -CipherName 'somecipher' + Add-NSLBSSLVirtualServerCipherSuiteBinding -VirtualServerName 'vserver01' -CipherName 'somecipher' Adds the binding of the SSL cipher suite 'somecipher' to virtual server 'vserver01'. @@ -73,7 +73,7 @@ function Add-NSLBSSLCipherSuiteBinding { _InvokeNSRestApi -Session $Session -Method PUT -Type sslvserver_sslciphersuite_binding -Payload $params if ($PSBoundParameters.ContainsKey('PassThru')) { - return Get-NSLBSSLCipherSuiteBinding -Session $Session -VirtualServerName $VirtualServerName + return Get-NSLBSSLVirtualServerCipherSuiteBinding -Session $Session -VirtualServerName $VirtualServerName } } catch { throw $_ diff --git a/NetScaler/Public/Get-NSLBSSLProfileToVserverBinding.ps1 b/NetScaler/Public/Get-NSLBSSLProfileToVserverBinding.ps1 new file mode 100644 index 0000000..e385188 --- /dev/null +++ b/NetScaler/Public/Get-NSLBSSLProfileToVserverBinding.ps1 @@ -0,0 +1,62 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Get-NSLBSSLProfileToVserverBinding { + <# + .SYNOPSIS + Display ssl profile bound to a vserver + + .DESCRIPTION + Display ssl profile bound to a vserver + + .EXAMPLE + Get-NSLBSSLProfileToVserverBinding -VirtualServerName somevserver + + Retrieve the ssl profile bound to 'somevserver' vserver + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VirtualServerName + Name of the SSL virtual server for which to set advanced configuration. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [Parameter(Mandatory)] + [string]$VirtualServerName + ) + + begin { + _AssertSessionActive + } + + process { + if ($PSCmdlet.ShouldProcess($VirtualServerName, 'Retrieve ssl profile bound (or not) to a virtualserver')) { + try { + $params = @{ + vservername = $VirtualServerName + } + $response = _InvokeNSRestApi -Session $Session -Method Get -Type sslvserver -Resource $VirtualServerName + $response.sslvserver + } + catch { + throw $_ + } + } + } +} diff --git a/NetScaler/Public/Get-NSLBSSLCipherGroupBinding.ps1 b/NetScaler/Public/Get-NSLBSSLVirtualServerCipherGroupBinding.ps1 similarity index 91% rename from NetScaler/Public/Get-NSLBSSLCipherGroupBinding.ps1 rename to NetScaler/Public/Get-NSLBSSLVirtualServerCipherGroupBinding.ps1 index 2052345..acf117d 100644 --- a/NetScaler/Public/Get-NSLBSSLCipherGroupBinding.ps1 +++ b/NetScaler/Public/Get-NSLBSSLVirtualServerCipherGroupBinding.ps1 @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. #> -function Get-NSLBSSLCipherGroupBinding { +function Get-NSLBSSLVirtualServerCipherGroupBinding { <# .SYNOPSIS Gets the specified load balancer SSL virtual server object binding to a cipher group. @@ -23,12 +23,12 @@ function Get-NSLBSSLCipherGroupBinding { Gets the specified load balancer SSL virtual server object binding to a cipher group .EXAMPLE - Get-NSLBSSLCipherBinding + Get-NSLBSSLVirtualServerCipherGroupBinding Get the cypher group bindings for all load balancer SSL virtual server objects. .EXAMPLE - Get-NSLBSSLCipherBinding -VirtualServerName 'vserver01' + Get-NSLBSSLVirtualServerCipherGroupBinding -VirtualServerName 'vserver01' Get the cipher group bindings for the load balancer SSL virtual server named 'vserver01'. diff --git a/NetScaler/Public/Get-NSLBSSLCipherSuiteBinding.ps1 b/NetScaler/Public/Get-NSLBSSLVirtualServerCipherSuiteBinding.ps1 similarity index 91% rename from NetScaler/Public/Get-NSLBSSLCipherSuiteBinding.ps1 rename to NetScaler/Public/Get-NSLBSSLVirtualServerCipherSuiteBinding.ps1 index d741159..ea622ad 100644 --- a/NetScaler/Public/Get-NSLBSSLCipherSuiteBinding.ps1 +++ b/NetScaler/Public/Get-NSLBSSLVirtualServerCipherSuiteBinding.ps1 @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. #> -function Get-NSLBSSLCipherSuiteBinding { +function Get-NSLBSSLVirtualServerCipherSuiteBinding { <# .SYNOPSIS Gets the specified load balancer SSL virtual server object. @@ -23,12 +23,12 @@ function Get-NSLBSSLCipherSuiteBinding { Gets the specified load balancer SSL virtual server object. .EXAMPLE - Get-NSLBSSLCipherSuiteBinding + Get-NSLBSSLVirtualServerCipherSuiteBinding Get the cypher suite bindings for all load balancer SSL virtual server objects. .EXAMPLE - Get-NSLBSSLCipherSuiteBinding -VirtualServerName 'vserver01' + Get-NSLBSSLVirtualServerCipherSuiteBinding -VirtualServerName 'vserver01' Get the cipher suite bindings for the load balancer SSL virtual server named 'vserver01'. diff --git a/NetScaler/Public/Get-NSResponderHTMLPage.ps1 b/NetScaler/Public/Get-NSResponderHTMLPage.ps1 index 7f7aa97..ecf3887 100644 --- a/NetScaler/Public/Get-NSResponderHTMLPage.ps1 +++ b/NetScaler/Public/Get-NSResponderHTMLPage.ps1 @@ -49,6 +49,6 @@ function Get-NSResponderHTMLPage { process { $response = _InvokeNSRestApiGet -Session $Session -Type responderhtmlpage -Name $Name - $response.name + if (!$response) { $response.name } } } \ No newline at end of file diff --git a/NetScaler/Public/New-NSLBServiceGroup.ps1 b/NetScaler/Public/New-NSLBServiceGroup.ps1 index 5769208..e56f70f 100644 --- a/NetScaler/Public/New-NSLBServiceGroup.ps1 +++ b/NetScaler/Public/New-NSLBServiceGroup.ps1 @@ -29,7 +29,7 @@ function New-NSLBServiceGroup { .EXAMPLE 'sg01' | New-NSLBServiceGroup -ServiceType HTTP -Comment 'test service group' - + Creates a new HTTP service group called 'sg01' with a comment. .PARAMETER Session @@ -65,10 +65,10 @@ function New-NSLBServiceGroup { Possible values = ENABLED, DISABLED .PARAMETER HealthMonitor - Monitor the health of this service. - Available settings function as follows: - YES - Send probes to check the health of the service. - NO - Do not send probes to check the health of the service. + Monitor the health of this service. + Available settings function as follows: + YES - Send probes to check the health of the service. + NO - Do not send probes to check the health of the service. With the NO option, the appliance shows the service as UP at all times. Default value: YES Possible values = YES, NO @@ -92,20 +92,20 @@ function New-NSLBServiceGroup { Possible values = ON, OFF .PARAMETER UseProxyPort - Use the proxy port as the source port when initiating connections with the server. - With the NO setting, the client-side connection port is used as the source port for the server-side connection. + Use the proxy port as the source port when initiating connections with the server. + With the NO setting, the client-side connection port is used as the source port for the server-side connection. Note: This parameter is available only when the Use Source IP (USIP) parameter is set to YES. Possible values = YES, NO .PARAMETER DownStateFlush - Flush all active transactions associated with all the services in the service group whose state transitions from UP to DOWN. + Flush all active transactions associated with all the services in the service group whose state transitions from UP to DOWN. Note: Do not enable this option for applications that must complete their transactions. Default value: ENABLED Possible values = ENABLED, DISABLED .PARAMETER UseClientIP - Use client's IP address as the source IP address when initiating connection to the server. - With the NO setting, which is the default, a mapped IP (MIP) address or subnet IP (SNIP) address + Use client's IP address as the source IP address when initiating connection to the server. + With the NO setting, which is the default, a mapped IP (MIP) address or subnet IP (SNIP) address is used as the source IP address to initiate server side connections. Possible values = YES, NO @@ -126,9 +126,9 @@ function New-NSLBServiceGroup { Possible values = ENABLED, DISABLED .PARAMETER ClientIPHeader - Name of the HTTP header whose value must be set to the IP address of the client. - Used with the Client IP parameter. If client IP insertion is enabled, and the - client IP header is not specified, the value of Client IP Header parameter or the + Name of the HTTP header whose value must be set to the IP address of the client. + Used with the Client IP parameter. If client IP insertion is enabled, and the + client IP header is not specified, the value of Client IP Header parameter or the value set by the set ns config command is used as client's IP header name. Minimum length = 1 @@ -138,7 +138,7 @@ function New-NSLBServiceGroup { Maximum value = 4294967287 .PARAMETER MonitorThreshold - Minimum sum of weights of the monitors that are bound to this service. + Minimum sum of weights of the monitors that are bound to this service. Used to determine whether to mark a service as UP or DOWN. Minimum value = 0 Maximum value = 65535 @@ -159,7 +159,7 @@ function New-NSLBServiceGroup { Minimum value = 0 Maximum value = 31536000 - .PARAMETER ServerIdleTimeout + .PARAMETER ServerIdleTimeout Time, in seconds, after which to terminate an idle server connection. Minimum value = 0 Maximum value = 31536000 diff --git a/NetScaler/Public/New-NSSSLProfile.ps1 b/NetScaler/Public/New-NSSSLProfile.ps1 index 1f1b3a7..8402375 100644 --- a/NetScaler/Public/New-NSSSLProfile.ps1 +++ b/NetScaler/Public/New-NSSSLProfile.ps1 @@ -104,9 +104,6 @@ function New-NSSSLProfile { [ValidateSet('FrontEnd','BackEnd')] [string]$ProfileType, - [ValidateSet('ENABLED','DISABLED')] - [string]$SSL2, - [ValidateSet('ENABLED','DISABLED')] [string]$SSL3, @@ -146,9 +143,6 @@ function New-NSSSLProfile { if ($PSBoundParameters.ContainsKey('DenySslRenegotiation')) { $params.Add('denysslreneg', $DenySslRenegotiation) } - if ($PSBoundParameters.ContainsKey('SSL2')) { - $params.Add('ssl2', $SSL2) - } if ($PSBoundParameters.ContainsKey('SSL3')) { $params.Add('ssl3', $SSL3) } diff --git a/NetScaler/Public/Remove-NSLBSSLProfileToVserverBinding.ps1 b/NetScaler/Public/Remove-NSLBSSLProfileToVserverBinding.ps1 new file mode 100644 index 0000000..0c8aed0 --- /dev/null +++ b/NetScaler/Public/Remove-NSLBSSLProfileToVserverBinding.ps1 @@ -0,0 +1,67 @@ +<# +Copyright 2017 Juan C. Herrera + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#> + +function Remove-NSLBSSLProfileToVserverBinding { + <# + .SYNOPSIS + Unbind a ssl profile from a vserver + + .DESCRIPTION + Unbind a ssl profile from a vserver + + .EXAMPLE + Remove-NSLBSSLProfileToVserverBinding -VirtualServerName 'somevserver' -SSLProfile 'somesslprofile' + + Unbind ssl profile 'somesslprofile' from vserver 'somevserver' + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VirtualServerName + Name of the SSL virtual server for which to set advanced configuration. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [Parameter(Mandatory)] + [string]$VirtualServerName, + + [Parameter(Mandatory)] + [bool]$SSLProfile = $false + + ) + + begin { + _AssertSessionActive + } + + process { + if ($PSCmdlet.ShouldProcess($VirtualServerName, "Unbind ssl profile from virtual Server $VirtualServerName")) { + try { + $params = @{ + sslprofile = $SSLProfile + vservername = $VirtualServerName + } + $response = _InvokeNSRestApi -Session $Session -Method POST -Type sslvserver -Payload $params -Action unset + $response + } + catch { + throw $_ + } + } + } +} diff --git a/NetScaler/Public/Remove-NSLBSSLVirtualServerCertificateBinding.ps1 b/NetScaler/Public/Remove-NSLBSSLVirtualServerCertificateBinding.ps1 index 1d754d6..a5ec89d 100644 --- a/NetScaler/Public/Remove-NSLBSSLVirtualServerCertificateBinding.ps1 +++ b/NetScaler/Public/Remove-NSLBSSLVirtualServerCertificateBinding.ps1 @@ -17,15 +17,15 @@ limitations under the License. function Remove-NSLBSSLVirtualServerCertificateBinding { <# .SYNOPSIS - Adds a new load balancer server certificate binding. + Unbinds a virtual server from a certificate certificate. .DESCRIPTION - Adds a new load balancer server certificate binding. + Unbinds a virtual server from a certificate certificate. .EXAMPLE - Add-NSLBSSLVirtualServerCertificateBinding -VirtualServerName 'vserver01' -Certificate 'cert' + Remove-NSLBSSLVirtualServerCertificateBinding -VirtualServerName 'vserver01' -Certificate 'cert' - Bind the SSL certificate 'cert' to virtual server 'vserver01'. + Unbinds the certificate 'cert' from virtual server 'vserver01'. .PARAMETER Session The NetScaler session object. diff --git a/NetScaler/Public/Remove-NSLBSSLCipherGroupBinding.ps1 b/NetScaler/Public/Remove-NSLBSSLVirtualServerCipherGroupBinding.ps1 similarity index 81% rename from NetScaler/Public/Remove-NSLBSSLCipherGroupBinding.ps1 rename to NetScaler/Public/Remove-NSLBSSLVirtualServerCipherGroupBinding.ps1 index 3967e07..6ffff58 100644 --- a/NetScaler/Public/Remove-NSLBSSLCipherGroupBinding.ps1 +++ b/NetScaler/Public/Remove-NSLBSSLVirtualServerCipherGroupBinding.ps1 @@ -14,18 +14,18 @@ See the License for the specific language governing permissions and limitations under the License. #> -function Remove-NSLBSSLCipherGroupBinding { +function Remove-NSLBSSLVirtualServerCipherGroupBinding { <# .SYNOPSIS - Removes a new load balancer cipher group binding. + Unbinds a new load balancer cipher group binding. .DESCRIPTION - Removes a new load balancer cipher group binding. + Unbinds a new load balancer cipher group binding. .EXAMPLE - Remove-NSLBSSLCipherBinding -VirtualServerName 'vserver01' -Ciphername 'somecipher' + Remove-NSLBSSLVirtualServerCipherGroupBinding -VirtualServerName 'vserver01' -Ciphername 'somecipher' - Removes the SSL cipher group 'somecipher' from the virtual server 'vserver01'. + Unbinds the SSL cipher group 'somecipher' from the virtual server 'vserver01'. .PARAMETER Session The NetScaler session object. @@ -73,7 +73,7 @@ function Remove-NSLBSSLCipherGroupBinding { _InvokeNSRestApi -Session $Session -Method DELETE -Type sslvserver_sslcipher_binding -Resource $VirtualServerName -Arguments $params -Action delete if ($PSBoundParameters.ContainsKey('PassThru')) { - return Get-NSLBSSLCipherGroupBinding -Session $Session -VirtualServerName $VirtualServerName + return Get-NSLBSSLVirtualServerCipherGroupBinding -Session $Session -VirtualServerName $VirtualServerName } } catch { throw $_ diff --git a/NetScaler/Public/Remove-NSLBSSLCipherSuiteBinding.ps1 b/NetScaler/Public/Remove-NSLBSSLVirtualServerCipherSuiteBinding.ps1 similarity index 78% rename from NetScaler/Public/Remove-NSLBSSLCipherSuiteBinding.ps1 rename to NetScaler/Public/Remove-NSLBSSLVirtualServerCipherSuiteBinding.ps1 index 356119c..bf9a63f 100644 --- a/NetScaler/Public/Remove-NSLBSSLCipherSuiteBinding.ps1 +++ b/NetScaler/Public/Remove-NSLBSSLVirtualServerCipherSuiteBinding.ps1 @@ -14,18 +14,18 @@ See the License for the specific language governing permissions and limitations under the License. #> -function Remove-NSLBSSLCipherSuiteBinding { +function Remove-NSLBSSLVirtualServerCipherSuiteBinding { <# .SYNOPSIS - Adds a new load balancer server certificate binding. + Unbinds a cipher suite from a virtual server .DESCRIPTION - Adds a new load balancer server certificate binding. + Unbinds a cipher suite from a virtual server .EXAMPLE - Add-NSLBSSLVirtualServerCertificateBinding -VirtualServerName 'vserver01' -Certificate 'cert' + Remove-NSLBSSLVirtualServerCipherSuiteBinding -VirtualServerName 'vserver01' -CipherName 'somecipher' - Bind the SSL certificate 'cert' to virtual server 'vserver01'. + Unbinds a cipher suite named 'somecipher' from the virtual server 'vserver01'. .PARAMETER Session The NetScaler session object. @@ -33,8 +33,8 @@ function Remove-NSLBSSLCipherSuiteBinding { .PARAMETER VirtualServerName Name of the SSL virtual server - .PARAMETER Certificate - The name of the certificate key pair binding. + .PARAMETER CipherName + The name of the cipher group .PARAMETER Passthru Return the load balancer server object. @@ -73,7 +73,7 @@ function Remove-NSLBSSLCipherSuiteBinding { _InvokeNSRestApi -Session $Session -Method DELETE -Type sslvserver_sslciphersuite_binding -Resource $VirtualServerName -Arguments $params -Action delete if ($PSBoundParameters.ContainsKey('PassThru')) { - return Get-NSLBSSLCipherSuiteBinding -Session $Session -VirtualServerName $VirtualServerName + return Get-NSLBSSLVirtualServerCipherSuiteBinding -Session $Session -VirtualServerName $VirtualServerName } } catch { throw $_ diff --git a/NetScaler/Public/Remove-NSVLAN.ps1 b/NetScaler/Public/Remove-NSVLAN.ps1 index 0ae9378..01435ef 100644 --- a/NetScaler/Public/Remove-NSVLAN.ps1 +++ b/NetScaler/Public/Remove-NSVLAN.ps1 @@ -17,15 +17,15 @@ limitations under the License. function Remove-NSVLAN { <# .SYNOPSIS - Deletes an untagged/unbound VLAN from NetScaler appliance. + Removes an untagged/unbound VLAN from NetScaler appliance. .DESCRIPTION - Deletes an untagged/unbound VLAN from NetScaler appliance. + Removes an untagged/unbound VLAN from NetScaler appliance. .EXAMPLE Remove-NSVLAN -VLANID 150 - Deletes VLAN 150 from the NetScaler appliance. + Removes VLAN 150 from the NetScaler appliance. .PARAMETER Session The NetScaler session object. diff --git a/NetScaler/Public/Remove-NSVLANInterfaceBinding.ps1 b/NetScaler/Public/Remove-NSVLANInterfaceBinding.ps1 index 751706d..a0856a5 100644 --- a/NetScaler/Public/Remove-NSVLANInterfaceBinding.ps1 +++ b/NetScaler/Public/Remove-NSVLANInterfaceBinding.ps1 @@ -17,15 +17,15 @@ limitations under the License. function Remove-NSVLANInterfaceBinding { <# .SYNOPSIS - Removes the binding of an interface as well as untagged/unbound from NetScaler appliance. + Unbinds an interface from a vlan .DESCRIPTION - Removes the binding of an interface as well as untagged/unbound from NetScaler appliance. + Unbinds an interface from a vlan .EXAMPLE Remove-NSVLANInterfaceBinding -VLANID 150 -interface '0/1' -tagged - Adds binding for interface '0/1' and tags the vlan on the NetScaler appliance. + Unbinds interface '0/1' from vlan 150 .PARAMETER Session The NetScaler session object. diff --git a/NetScaler/Public/Set-NSLBMonitor.ps1 b/NetScaler/Public/Set-NSLBMonitor.ps1 index 34a05ff..c746f60 100644 --- a/NetScaler/Public/Set-NSLBMonitor.ps1 +++ b/NetScaler/Public/Set-NSLBMonitor.ps1 @@ -426,14 +426,8 @@ function Set-NSLBMonitor { } } if ($PSBoundParameters.ContainsKey('ResponseCode')) { - ## Add each custom property to the $params Hashtable - foreach ($rc in $ResponseCode.Keys) { - $params.Add($rc.ToLower(), $ResponseCode[$rc]) - } - } - # if ($PSBoundParameters.ContainsKey('ResponseCode')) { - # $params.Add('respcode', $ResponseCode) - # } + $params.Add('respcode', $ResponseCode) + } if ($PSBoundParameters.ContainsKey('HTTPRequest')) { $params.Add('httprequest', $HTTPRequest) } diff --git a/NetScaler/Public/Set-NSLBServiceGroup.ps1 b/NetScaler/Public/Set-NSLBServiceGroup.ps1 index d943990..414cee6 100644 --- a/NetScaler/Public/Set-NSLBServiceGroup.ps1 +++ b/NetScaler/Public/Set-NSLBServiceGroup.ps1 @@ -46,7 +46,7 @@ function Set-NSLBServiceGroup { .PARAMETER State Initial state of the service group. Default value: ENABLED - Possible values = ENABLED, DISABLED + Possible values = ENABLED, DISABLED .PARAMETER AutoScale Auto scale option for a servicegroup. @@ -186,7 +186,7 @@ function Set-NSLBServiceGroup { [ValidateRange(0, 31536000)] [int]$ServerIdleTimeout = 360, - [Switch]$Force, + [Switch]$Force, [Switch]$PassThru ) @@ -200,17 +200,19 @@ function Set-NSLBServiceGroup { if ($Force -or $PSCmdlet.ShouldProcess($item, 'Edit Service Group')) { $params = @{ servicegroupname = $item - state = $State - } + } + if ($PSBoundParameters.ContainsKey('State')) { + $params.Add('state', $State) + } if ($PSBoundParameters.ContainsKey('CacheType')) { $params.Add('cachetype', $CacheType) - } + } if ($PSBoundParameters.ContainsKey('Cacheable')) { $params.Add('cacheable', $Cacheable) } if ($PSBoundParameters.ContainsKey('AutoScale')) { $params.Add('autoScale', $AutoScale) - } + } if ($PSBoundParameters.ContainsKey('HealthMonitor')) { $params.Add('healthmonitor', $HealthMonitor) } diff --git a/NetScaler/Public/Set-NSNTPServer.ps1 b/NetScaler/Public/Set-NSNTPServer.ps1 index fcf94e2..aa7da72 100644 --- a/NetScaler/Public/Set-NSNTPServer.ps1 +++ b/NetScaler/Public/Set-NSNTPServer.ps1 @@ -1,5 +1,5 @@ <# -Copyright 2016 Juan C. Herrera +Copyright 2017 Juan C. Herrera Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 8b666870a0a988a524041379507513fd665a7785 Mon Sep 17 00:00:00 2001 From: Herrera Date: Mon, 13 Nov 2017 15:41:39 -0800 Subject: [PATCH 6/7] revised some functions, added new functionality --- NetScaler/NetScaler.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NetScaler/NetScaler.psd1 b/NetScaler/NetScaler.psd1 index a95074a..84545c0 100644 --- a/NetScaler/NetScaler.psd1 +++ b/NetScaler/NetScaler.psd1 @@ -12,7 +12,7 @@ RootModule = 'NetScaler.psm1' # Version number of this module. -ModuleVersion = '1.5.2' +ModuleVersion = '1.6.1' # ID used to uniquely identify this module GUID = 'bd4390dc-a8ad-4bce-8d69-f53ccf8e4163' From 8f7d6b817c460f1e0894a467e1cd5864c9a45a53 Mon Sep 17 00:00:00 2001 From: Herrera Date: Tue, 30 Jan 2018 23:40:14 -0800 Subject: [PATCH 7/7] modified function set-nslbvirtualserver to correct action call to api as it is no longer supported in v11 --- NetScaler/NetScaler.psd1 | 4 +++ NetScaler/Public/Set-NSLBVirtualServer.ps1 | 36 +++++++++------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/NetScaler/NetScaler.psd1 b/NetScaler/NetScaler.psd1 index 84545c0..09dd092 100644 --- a/NetScaler/NetScaler.psd1 +++ b/NetScaler/NetScaler.psd1 @@ -160,6 +160,7 @@ FunctionsToExport = @( 'Get-NSSSLCertificate', 'Get-NSSSLCertificateLink', 'Get-NSSSLProfile', + 'Get-NSTCPProfile', 'Get-NSLBSSLProfileToVserverBinding', 'Get-NSSystemFile', 'Get-NSTimeZone', @@ -195,6 +196,7 @@ FunctionsToExport = @( 'New-NSRewritePolicy', 'New-NSNTPServer', 'New-NSSSLProfile', + 'New-NSTCPProfile', 'New-NSVPNSessionPolicy', 'New-NSVPNSessionProfile', 'New-NSVPNVirtualServer', @@ -228,6 +230,7 @@ FunctionsToExport = @( 'Remove-NSRewriteAction', 'Remove-NSSSLCertificateLink', 'Remove-NSSSLProfile', + 'Remove-NSTCPProfile', 'Remove-NSLBSSLProfileToVserverBinding', 'Remove-NSSystemFile', 'Remove-NSVLAN', @@ -253,6 +256,7 @@ FunctionsToExport = @( 'Set-NSRewriteAction', 'Set-NSRewritePolicy', 'Set-NSSSLProfile', + 'Set-NSTCPProfile', 'Set-NSVLAN', 'Set-NSTimeZone', 'Set-NSVPNVirtualServerTheme' diff --git a/NetScaler/Public/Set-NSLBVirtualServer.ps1 b/NetScaler/Public/Set-NSLBVirtualServer.ps1 index 06f0628..ab5ca4d 100644 --- a/NetScaler/Public/Set-NSLBVirtualServer.ps1 +++ b/NetScaler/Public/Set-NSLBVirtualServer.ps1 @@ -92,9 +92,8 @@ function Set-NSLBVirtualServer { [string[]]$Name = (Read-Host -Prompt 'LB virtual server name'), [ValidateSet('ROUNDROBIN', 'LEASTCONNECTION', 'LEASTRESPONSETIME', 'LEASTBANDWIDTH', 'LEASTPACKETS', 'CUSTOMLOAD', 'LRTM', 'URLHASH', 'DOMAINHASH', 'DESTINATIONIPHASH', 'SOURCEIPHASH', 'TOKEN', 'SRCIPDESTIPHASH', 'SRCIPSRCPORTHASH', 'CALLIDHASH')] - [string]$LBMethod = 'ROUNDROBIN', + [string]$LBMethod, - [Parameter()] [ValidateSet('SOURCEIP', 'COOKIEINSERT', 'SSLSESSION', 'CUSTOMSERVERID', 'RULE', 'URLPASSIVE', 'DESTIP', 'SRCIPDESTIP', 'CALLID' ,'RTSPID', 'FIXSESSION', 'NONE')] [string] $PersistenceType, @@ -102,31 +101,22 @@ function Set-NSLBVirtualServer { [ValidateScript({$_ -match [IPAddress]$_ })] [string]$IPAddress, - [Parameter()] - [string] - $HttpRedirectURL, + [string]$HttpRedirectURL, - [Parameter()] [ValidateLength(0, 256)] - [string]$Comment = '', + [string]$Comment, - [Parameter()] - [ValidateLength(0, 256)] - [string]$ICMPVSRResponse = 'PASSIVE', + [ValidateSet('PASSIVE', 'ACTIVE')] + [string]$ICMPVSRResponse, - [Parameter()] - [int]$TimeOut = 2, + [int]$TimeOut, - [Parameter()] [int]$ClientTimeout, - [Parameter()] - [string] - $BackupVServer, + [string]$BackupVServer, - [Parameter()] [ValidateSet('ENABLED', 'DISABLED')] - [string]$RedirectPortRewrite = 'DISABLED', + [string]$RedirectPortRewrite, [Switch]$Force, @@ -142,8 +132,12 @@ function Set-NSLBVirtualServer { if ($Force -or $PSCmdlet.ShouldProcess($item, 'Edit Virtual Server')) { $params = @{ name = $item - timeout = $TimeOut - icmpvsrresponse = $ICMPVSRResponse + } + if ($PSBoundParameters.ContainsKey('TimeOut')) { + $params.Add('timeout', $TimeOut) + } + if ($PSBoundParameters.ContainsKey('ICMPVSRResponse')) { + $params.Add('icmpvsrresponse', $ICMPVSRResponse) } if ($PSBoundParameters.ContainsKey('LBMethod')) { $params.Add('lbmethod', $LBMethod) @@ -169,7 +163,7 @@ function Set-NSLBVirtualServer { if ($PSBoundParameters.ContainsKey('RedirectPortRewrite')) { $params.Add('RedirectPortRewrite', $RedirectPortRewrite) } - _InvokeNSRestApi -Session $Session -Method PUT -Type lbvserver -Payload $params -Action update + _InvokeNSRestApi -Session $Session -Method PUT -Type lbvserver -Payload $params #-Action update if ($PSBoundParameters.ContainsKey('PassThru')) { return Get-NSLBVirtualServer -Session $Session -Name $item