diff --git a/NetScaler/NetScaler.psd1 b/NetScaler/NetScaler.psd1 index 701f07d..09dd092 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.6.1' # ID used to uniquely identify this module GUID = 'bd4390dc-a8ad-4bce-8d69-f53ccf8e4163' @@ -72,8 +72,13 @@ FunctionsToExport = @( 'Add-NSDnsNameServer', 'Add-NSDnsSuffix', 'Add-NSIPResource', + 'Add-NSLBServiceGroupMemberBinding', 'Add-NSLBServiceGroupMonitorBinding', + 'Add-NSLBServiceMonitorBinding', + 'Add-NSLBSSLProfileToVserverBinding', 'Add-NSLBSSLVirtualServerCertificateBinding', + 'Add-NSLBSSLVirtualServerCipherGroupBinding', + 'Add-NSLBSSLVirtualServerCipherSuiteBinding', 'Add-NSLBVirtualServerBinding', 'Add-NSCSVirtualServerPolicyBinding', 'Add-NSLBVirtualServerResponderPolicyBinding', @@ -83,6 +88,8 @@ FunctionsToExport = @( 'Add-NSServerCertificate', 'Add-NSSSLCertificateLink', 'Add-NSSystemFile', + 'Add-NSVLAN', + 'Add-NSVLANInterfaceBinding', 'Add-NSVPNVirtualServerBinding', 'Clear-NSAAASession', 'Clear-NSConfig', @@ -105,6 +112,7 @@ FunctionsToExport = @( 'Get-NSAAAVirtualServer', 'Get-NSAvailableTimeZone', 'Get-NSBackup', + 'Get-NSCertKeyPair', 'Get-NSConfig', 'Get-NSCSAction', 'Get-NSCSPolicy', @@ -120,10 +128,14 @@ FunctionsToExport = @( 'Get-NSKCDAccount', 'Get-NSLBMonitor', 'Get-NSLBServer', + 'Get-NSLBService', 'Get-NSLBServiceGroup', 'Get-NSLBServiceGroupMemberBinding', 'Get-NSLBServiceGroupMonitorBinding', + 'Get-NSLBServiceMonitorBinding', 'Get-NSLBSSLVirtualServer', + 'Get-NSLBSSLVirtualServerCipherGroupBinding', + 'Get-NSLBSSLVirtualServerCipherSuiteBinding', 'Get-NSLBSSLVirtualServerCertificateBinding', 'Get-NSLBSSLVirtualServerProfile', 'Get-NSLBStat', @@ -136,6 +148,7 @@ FunctionsToExport = @( 'Get-NSLDAPAuthenticationPolicy', 'Get-NSLDAPAuthenticationServer', 'Get-NSResponderAction', + 'Get-NSResponderHTMLPage', 'Get-NSResponderPolicy', 'Get-NSRewriteAction', 'Get-NSRewritePolicy', @@ -147,15 +160,20 @@ FunctionsToExport = @( 'Get-NSSSLCertificate', 'Get-NSSSLCertificateLink', 'Get-NSSSLProfile', + 'Get-NSTCPProfile', + 'Get-NSLBSSLProfileToVserverBinding', 'Get-NSSystemFile', 'Get-NSTimeZone', 'Get-NSVersion', + 'Get-NSVLAN', + 'Get-NSVLANBindings', 'Get-NSVPNServer', 'Get-NSVPNSessionPolicy', 'Get-NSVPNSessionProfile', 'Get-NSVPNVirtualServer', 'Get-NSVPNVirtualServerBinding', 'Get-NSVPNVirtualServerTheme', + 'Import-NSCertFile', 'Install-NSLicense', 'Invoke-Nitro', 'New-NSBackup', @@ -164,49 +182,82 @@ FunctionsToExport = @( 'New-NSKCDAccount', 'New-NSLBMonitor', 'New-NSLBServer', + 'New-NSLBService', 'New-NSLBServiceGroup', - 'New-NSLBServiceGroupMember', 'New-NSLBServiceGroupMonitor', 'New-NSLBVirtualServer', 'New-NSLDAPAuthenticationPolicy', 'New-NSLDAPAuthenticationServer', 'New-NSNTPServer', 'New-NSResponderAction', + 'New-NSResponderHTMLPage', 'New-NSResponderPolicy', 'New-NSRewriteAction', 'New-NSRewritePolicy', 'New-NSNTPServer', 'New-NSSSLProfile', + 'New-NSTCPProfile', 'New-NSVPNSessionPolicy', 'New-NSVPNSessionProfile', 'New-NSVPNVirtualServer', 'Remove-NSBackup', + 'Remove-NSCertFile', + 'Remove-NSCertKeyPair', + 'Remove-NSDnsNameServer', 'Remove-NSDnsSuffix', + 'Remove-NSIPResource', 'Remove-NSLBMonitor', 'Remove-NSLBServer', + 'Remove-NSLBService', 'Remove-NSLBServiceGroup', + 'Remove-NSLBServiceGroupMemberBinding', 'Remove-NSLBServiceGroupMonitorBinding', + 'Remove-NSLBServiceMonitorBinding', 'Remove-NSLBVirtualServer', 'Remove-NSLBVirtualServerBinding', + 'Remove-NSLBSSLVirtualServerCertificateBinding', + 'Remove-NSLBSSLVirtualServerCipherGroupBinding', + 'Remove-NSLBSSLVirtualServerCipherSuiteBinding', 'Remove-NSLBSSLVirtualServerProfile', + 'Remove-NSLBVirtualServerResponderPolicyBinding', 'Remove-NSLDAPAuthenticationPolicy', 'Remove-NSLDAPAuthenticationServer', + 'Remove-NSNTPServer', 'Remove-NSResponderAction', + 'Remove-NSResponderHTMLPage', + 'Remove-NSResponderPolicy', + 'Remove-NSRewritePolicy', + 'Remove-NSRewriteAction', 'Remove-NSSSLCertificateLink', 'Remove-NSSSLProfile', + 'Remove-NSTCPProfile', + 'Remove-NSLBSSLProfileToVserverBinding', '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-NSLBService', 'Set-NSLBServiceGroup', 'Set-NSLBSSLVirtualServer', 'Set-NSLBSSLVirtualServerProfile', 'Set-NSLBVirtualServer', + 'Set-NSMode', + 'Set-NSNTPServer', 'Set-NSResponderAction', + 'Set-NSResponderPolicy', + 'Set-NSRewriteAction', + 'Set-NSRewritePolicy', 'Set-NSSSLProfile', + 'Set-NSTCPProfile', + 'Set-NSVLAN', 'Set-NSTimeZone', 'Set-NSVPNVirtualServerTheme' ) 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-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-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-NSLBSSLVirtualServerCipherGroupBinding.ps1 b/NetScaler/Public/Add-NSLBSSLVirtualServerCipherGroupBinding.ps1 new file mode 100644 index 0000000..14290bb --- /dev/null +++ b/NetScaler/Public/Add-NSLBSSLVirtualServerCipherGroupBinding.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-NSLBSSLVirtualServerCipherGroupBinding { + <# + .SYNOPSIS + Adds a new load balancer server to cipher group binding. + + .DESCRIPTION + Adds a new load balancer server to cipher group binding. + + .EXAMPLE + Add-NSLBSSLVirtualServerCipherGroupBinding -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 -action add + + if ($PSBoundParameters.ContainsKey('PassThru')) { + return Get-NSLBSSLVirtualServerCipherGroupBinding -Session $Session -VirtualServerName $VirtualServerName + } + } catch { + throw $_ + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Add-NSLBSSLVirtualServerCipherSuiteBinding.ps1 b/NetScaler/Public/Add-NSLBSSLVirtualServerCipherSuiteBinding.ps1 new file mode 100644 index 0000000..6d385f5 --- /dev/null +++ b/NetScaler/Public/Add-NSLBSSLVirtualServerCipherSuiteBinding.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-NSLBSSLVirtualServerCipherSuiteBinding { + <# + .SYNOPSIS + Adds a new load balancer server to cipher suite binding. + + .DESCRIPTION + Adds a new load balancer server to cipher suite binding. + + .EXAMPLE + Add-NSLBSSLVirtualServerCipherSuiteBinding -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-NSLBSSLVirtualServerCipherSuiteBinding -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 88% rename from NetScaler/Public/New-NSLBServiceGroupMember.ps1 rename to NetScaler/Public/Add-NSLBServiceGroupMemberBinding.ps1 index abd2930..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, @@ -83,16 +83,16 @@ function New-NSLBServiceGroupMember { [ValidateRange(1, 65535)] [int]$Port = 80, + [ValidateSet('ENABLED', 'DISABLED')] + [string]$State = 'ENABLED', + [ValidateRange(1, 100)] [int]$Weight = 1, - [int]$ServerId, + [int]$ServerId = 0, [ValidateRange(1, [int]::MaxValue)] - [int]$HashId, - - [ValidateSet('ENABLED', 'DISABLED')] - [string]$State = 'ENABLED', + [int]$HashId = 0, [switch]$PassThru ) @@ -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,13 +110,15 @@ function New-NSLBServiceGroupMember { servicegroupname = $item servername = $member port = $Port - weight = $Weight state = $State + weight = $Weight + serverid = $ServerId + hashid = $Hashid } _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-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-NSLBVirtualServerResponderPolicyBinding.ps1 b/NetScaler/Public/Add-NSLBVirtualServerResponderPolicyBinding.ps1 index dcb9cfe..e09c9bf 100644 --- a/NetScaler/Public/Add-NSLBVirtualServerResponderPolicyBinding.ps1 +++ b/NetScaler/Public/Add-NSLBVirtualServerResponderPolicyBinding.ps1 @@ -62,7 +62,7 @@ function Add-NSLBVirtualServerResponderPolicyBinding { [string] $PolicyName, - [parameter(Mandatory=$True)] + [parameter()] [ValidateSet('REQUEST', 'RESPONSE')] [string] $Bindpoint, diff --git a/NetScaler/Public/Add-NSVLAN.ps1 b/NetScaler/Public/Add-NSVLAN.ps1 new file mode 100644 index 0000000..d8361f5 --- /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..29fa612 --- /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()] + [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-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-NSLBSSLVirtualServerCipherGroupBinding.ps1 b/NetScaler/Public/Get-NSLBSSLVirtualServerCipherGroupBinding.ps1 new file mode 100644 index 0000000..acf117d --- /dev/null +++ b/NetScaler/Public/Get-NSLBSSLVirtualServerCipherGroupBinding.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-NSLBSSLVirtualServerCipherGroupBinding { + <# + .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-NSLBSSLVirtualServerCipherGroupBinding + + Get the cypher group bindings for all load balancer SSL virtual server objects. + + .EXAMPLE + Get-NSLBSSLVirtualServerCipherGroupBinding -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-NSLBSSLVirtualServerCipherSuiteBinding.ps1 b/NetScaler/Public/Get-NSLBSSLVirtualServerCipherSuiteBinding.ps1 new file mode 100644 index 0000000..ea622ad --- /dev/null +++ b/NetScaler/Public/Get-NSLBSSLVirtualServerCipherSuiteBinding.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-NSLBSSLVirtualServerCipherSuiteBinding { + <# + .SYNOPSIS + Gets the specified load balancer SSL virtual server object. + + .DESCRIPTION + Gets the specified load balancer SSL virtual server object. + + .EXAMPLE + Get-NSLBSSLVirtualServerCipherSuiteBinding + + Get the cypher suite bindings for all load balancer SSL virtual server objects. + + .EXAMPLE + Get-NSLBSSLVirtualServerCipherSuiteBinding -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-NSLBService.ps1 b/NetScaler/Public/Get-NSLBService.ps1 new file mode 100644 index 0000000..eb64c47 --- /dev/null +++ b/NetScaler/Public/Get-NSLBService.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-NSLBService { + <# + .SYNOPSIS + Gets the specified load balancer service group object. + + .DESCRIPTION + Gets the specified load balancer service group object. + + .EXAMPLE + Get-NSLBService + + Get all load balancer service objects. + + .EXAMPLE + Get-NSLBService -Name 'service01' + + Get the load balancer service named 'service01'. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER Name + The name or names of the load balancer service to get. + #> + [cmdletbinding()] + param( + $Session = $script:session, + + [parameter(ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName)] + [string[]]$Name = @() + ) + + begin { + _AssertSessionActive + $service = @() + } + + process { + if ($Name.Count -gt 0) { + foreach ($item in $Name) { + $service = _InvokeNSRestApi -Session $Session -Method Get -Type service -Action Get -Resource $item + if ($Service.psobject.properties.name -contains 'service') { + return $service.service + } + } + } else { + $service = _InvokeNSRestApi -Session $Session -Method Get -Type service -Action Get + if ($Service.psobject.properties.name -contains 'service') { + return $service.service + } + } + } +} \ 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 new file mode 100644 index 0000000..ecf3887 --- /dev/null +++ b/NetScaler/Public/Get-NSResponderHTMLPage.ps1 @@ -0,0 +1,54 @@ +<# +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-NSResponderHTMLPage { + <# + .SYNOPSIS + Retrieve a responder HTML page from the NetScaler appliance. + + .DESCRIPTION + Retrieve a responder HTML page from the NetScaler appliance. + + .EXAMPLE + Get-NSResponderHTMLPage -Name 'myHTMLpage' + + Creates a root certificate key pair named 'myrootCA' using the PEM formatted certificate 'mycertificate.cert' located on 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 + ) + + begin { + _AssertSessionActive + } + + process { + $response = _InvokeNSRestApiGet -Session $Session -Type responderhtmlpage -Name $Name + if (!$response) { $response.name } + } +} \ 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..927b0d5 --- /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/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-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 new file mode 100644 index 0000000..0acfedc --- /dev/null +++ b/NetScaler/Public/New-NSLBService.ps1 @@ -0,0 +1,472 @@ +<# +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 New-NSLBService { + <# + .SYNOPSIS + Adds a new service to the loadbalancer. + + .DESCRIPTION + Adds a new service to the loadbalancer. + + .EXAMPLE + New-NSLBService -Name 'service01' + + Creates a new service called 'service01' + + .EXAMPLE + 'service01' | New-NSLBService -ServiceType HTTP -Comment 'test service' + + Creates a new HTTP service called 'service01' with a comment. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER Name + The name of the service to create. + + .PARAMETER ServiceType + Protocol used to exchange data with the service. + + .PARAMETER Servername + Name of the server that hosts the service. Cannot be used in combination with the 'IPAddress' option + Minimum length = 1 + + .PARAMETER IPAddress + IP to assign to the service. Cannot be used in combination with the 'ServerName' option + Minimum length = 1 + + .PARAMETER Port + Port number of the service. + Range 1 - 65535 + + .PARAMETER ClearTextPort + Port to which clear text data must be sent after the appliance decrypts incoming SSL traffic. Applicable to transparent SSL services. Minimum value is 1 + + .PARAMETER CacheType + Cache type supported by the cache server. + + .PARAMETER Cacheable + Use the transparent cache redirection virtual server to forward the request to the cache server. + Note: Do not set this parameter if you set the Cache Type. + Default value: NO + Possible values = YES, NO + + .PARAMETER State + Initial state of the service. + Default value: ENABLED + 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. + With the NO option, the appliance shows the service as UP at all times. + Default value: YES + Possible values = YES, NO + + .PARAMETER AppFlowLog + Enable logging of AppFlow information for the specified service. + Default value: ENABLED + Possible values = ENABLED, DISABLED + + .PARAMETER Comment + Any information about the service. + + .PARAMETER SureConnect + State of the SureConnect feature for the service. + Default value: OFF + Possible values = ON, OFF + + .PARAMETER SurgeProtection + Enable surge protection for the service. + Default value: OFF + 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. + 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. + 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 + is used as the source IP address to initiate server side connections. + Possible values = YES, NO + + .PARAMETER ClientKeepAlive + Enable client keep-alive for the service. + Possible values = YES, NO + + .PARAMETER TCPBuffering + Enable TCP buffering for the service. + Possible values = YES, NO + + .PARAMETER HTTPCompression + Enable compression for the specified service. + Possible values = YES, NO + + .PARAMETER ClientIP + Insert the Client IP header in requests forwarded to the service. + 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 + value set by the set ns config command is used as client's IP header name. + Minimum length = 1 + + .PARAMETER PathMonitor + Path monitoring for clustering. + Possible values = YES, NO + + .PARAMETER PathMonitorIndividual + Individual Path monitoring decisions. + Possible values = YES, NO + + .PARAMETER RTPSessionIDRemap + Enable RTSP session ID mapping for the service. + Default value: OFF + Possible values = ON, OFF + + .PARAMETER CustomServerID + Unique identifier for the service. Used when the persistency type for the virtual server is set to Custom Server ID. + Default value: "None" + + .PARAMETER ServerID + 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 + + .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 + + .PARAMETER TCPProfileName + Name of the TCP profile that contains TCP configuration settings for the service. + Minimum length = 1 + Maximum length = 127 + + .PARAMETER HTTPProfileName + Name of the HTTP profile that contains HTTP configuration settings for the service. + Minimum length = 1 + Maximum length = 127 + + .PARAMETER NetProfile + Minimum length = 1 + Maximum length = 127 + .PARAMETER TrafficDomain + Integer value that uniquely identifies the traffic domain in which you want to configure the entity. If you do not specify an ID, the entity becomes part of the default traffic domain, which has an ID of 0. + Minimum value = 0 + Maximum value = 4094 + .PARAMETER ProcessLocal + By turning on this option packets destined to a service in a cluster will not under go any steering. Turn this option for single packet request response mode or when the upstream device is performing a proper RSS for connection based distribution. + Default value: DISABLED + Possible values = ENABLED, DISABLED + + .PARAMETER MonitorThreshold + 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 + + .PARAMETER MaxRequests + Maximum number of requests that can be sent on a persistent connection to the service. + Note: Connection requests beyond this value are rejected. + Minimum value = 0 + Maximum value = 65535 + + .PARAMETER MaxClients + Maximum number of simultaneous open connections for the service. + Minimum value = 0 + Maximum value = 4294967294 + + .PARAMETER ClientIdleTimeout + Time, in seconds, after which to terminate an idle client connection. + Minimum value = 0 + Maximum value = 31536000 + + .PARAMETER ServerIdleTimeout + Time, in seconds, after which to terminate an idle server connection. + Minimum value = 0 + Maximum value = 31536000 + + .PARAMETER Passthru + Return the newly created service group. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [parameter(Mandatory, ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName = $true)] + [string[]]$Name = (Read-Host -Prompt 'LB service group name'), + + [ValidateSet('ADNS','ADNS_TCP','ANY','DHCPRA','DIAMETER','DNS','DNS_TCP','DTLS','FTP','HTTP','MSSQL','MYSQL','NNTP','RADIUS','RDP','RPCSVR','RTSP','SIP_UDP','SNMP','SSL','SSL_BRIDGE','SSL_DIAMETER','SSL_TCP','TCP','TFTP','UDP')] + [Alias('Protocol')] + [string]$ServiceType = 'HTTP', + + [parameter(ParameterSetName='IPAddress')] + [ValidateScript({$_ -match [IPAddress]$_ })] + [string]$IPAddress, + + [ValidateRange(0, 10000)] + [int]$Port = 80, + + [parameter(ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName = $true)] + [string[]]$ServerName, + + [ValidateRange(0, 4094)] + [int]$ClearTextPort = 1, + + [ValidateSet('FORWARD','TRANSPARENT','REVERSE')] + [string]$CacheType, + + [ValidateSet('NO', 'YES')] + [string]$Cacheable = 'NO', + + [ValidateSet('ENABLED', 'DISABLED')] + [string]$State = 'ENABLED', + + [ValidateSet('NO', 'YES')] + [string]$HealthMonitor = 'YES', + + [ValidateSet('DISABLED', 'ENABLED')] + [string]$AppFlowLog = 'ENABLED', + + [ValidateLength(0, 256)] + [string]$Comment = [string]::Empty, + + [ValidateSet('ON', 'OFF')] + [string]$SureConnect = 'OFF', + + [ValidateSet('ON', 'OFF')] + [string]$SurgeProtection = 'OFF', + + [ValidateSet('YES','NO')] + [string]$UseProxyPort = 'YES', + + [ValidateSet('ENABLED','DISABLED')] + [string]$DownStateFlush = 'ENABLED', + + [ValidateSet('YES','NO')] + [string]$UseClientIP = 'NO', + + [ValidateSet('YES','NO')] + [string]$ClientKeepAlive = 'NO', + + [ValidateSet('YES', 'NO')] + [string]$TCPBuffering = 'NO', + + [ValidateSet('YES', 'NO')] + [string]$HTTPCompression = 'YES', + + [ValidateSet('ENABLED','DISABLED')] + [string]$ClientIP = 'DISABLED', + + [string]$ClientIPHeader, + + [ValidateSet('YES', 'NO')] + [string]$PathMonitor, + + [ValidateSet('YES', 'NO')] + [string]$PathMonitorIndividual, + + [ValidateSet('On', 'OFF')] + [string]$RTPSessionIDRemap = 'OFF', + + [string]$CustomServerID = 'None', + + [ValidateRange(0, 4294967287)] + [int]$MaxBandwidthKbps, + + [ValidateSet('YES', 'NO')] + [string]$AccessDown = 'No', + + [string]$TCPProfileName, + + [string]$HTTPProfileName, + + [string]$NetProfileName, + + [ValidateRange(0, 4294967287)] + [int]$HashID, + + [string]$ProcessLocal, + + [ValidateRange(0, 4294967287)] + [int]$TrafficDomain, + + [ValidateRange(0, 65535)] + [int]$ServerID, + + [ValidateRange(0, 65535)] + [int]$MonitorThreshold, + + [ValidateRange(0, 65535)] + [int]$MaxRequests, + + [ValidateRange(0, 4294967294)] + [int]$MaxClients, + + [ValidateRange(0, 31536000)] + [int]$ClientIdleTimeout = 180, + + [ValidateRange(0, 31536000)] + [int]$ServerIdleTimeout = 360, + + [Switch]$PassThru + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $Name) { + if ($PSCmdlet.ShouldProcess($item, 'Create Service Group')) { + try { + $params = @{ + name = $item + servicetype = $ServiceType + port = $Port + servername = $ServerName + state = $State + comment = $Comment + } + 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) + } + if ($PSBoundParameters.ContainsKey('ClearTextPort')) { + $params.Add('cleartextport', $ClearTextPort) + } + if ($PSBoundParameters.ContainsKey('CacheType')) { + $params.Add('cachetype', $CacheType) + } + if ($PSBoundParameters.ContainsKey('ClientIPHeader')) { + $params.Add('cipheader', $ClientIPHeader) + } + if ($PSBoundParameters.ContainsKey('PathMonitor')) { + $params.Add('pathmonitor', $PathMonitor) + } + if ($PSBoundParameters.ContainsKey('PathMonitorIndv')) { + $params.Add('pathmonitorindv', $PathMonitorIndividual) + } + if ($PSBoundParameters.ContainsKey('RTPSessionIDRemap')) { + $params.Add('rtpsessionidremap', $RTPSessionIDRemap) + } + if ($PSBoundParameters.ContainsKey('CustomServerID')) { + $params.Add('customserverid', $CustomServerID) + } + if ($PSBoundParameters.ContainsKey('ServerID')) { + $params.Add('serverid', $ServerID) + } + if ($PSBoundParameters.ContainsKey('MaxBandwidthKbps')) { + $params.Add('maxbandwidth', $MaxBandwidthKbps) + } + if ($PSBoundParameters.ContainsKey('AccessDown')) { + $params.Add('accessdown', $AccessDown) + } + 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) + } + if ($PSBoundParameters.ContainsKey('MaxRequests')) { + $params.Add('maxreq', $MaxRequests) + } + if ($PSBoundParameters.ContainsKey('MaxClients')) { + $params.Add('maxclient', $MaxClients) + } + _InvokeNSRestApi -Session $Session -Method POST -Type service -Payload $params -Action add + + if ($PSBoundParameters.ContainsKey('PassThru')) { + return Get-NSLBService -Session $Session -Name $item + } + } catch { + throw $_ + } + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/New-NSLBServiceGroup.ps1 b/NetScaler/Public/New-NSLBServiceGroup.ps1 index 10a17c3..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,19 +126,19 @@ 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 - .PARAMETER MaxBandwithKbps + .PARAMETER MaxBandwidthKbps Maximum bandwidth, in Kbps, allocated for all the services in the service group. Minimum value = 0 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 @@ -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 d8e7880..95ff382 100644 --- a/NetScaler/Public/New-NSLBVirtualServer.ps1 +++ b/NetScaler/Public/New-NSLBVirtualServer.ps1 @@ -32,6 +32,11 @@ function New-NSLBVirtualServer { Create a new virtual server named 'vserver01' listening on port 8080 with a load balancing method of 'ROUNDROBIN'. + .EXAMPLE + New-NSLBVirtualServer -Name 'vserver01' -IPAddress '0.0.0.0' -Port 0 -ServiceType SSL + + Create a non-addressable new virtual server named 'vserver01' with an IP address of '0.0.0.0' set to non-addressable + .PARAMETER Session The NetScaler session object. @@ -47,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. @@ -112,15 +117,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. @@ -135,6 +135,20 @@ function New-NSLBVirtualServer { Minimum value = 0 Maximum value = 1440 + .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 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. #> @@ -144,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(1, 65534)] + [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', @@ -171,22 +185,27 @@ function New-NSLBVirtualServer { $PersistenceType, [Parameter()] - [ValidateRange(1, 65535)] - [int] - $RedirectFromPort, + [ValidateSet('PASSIVE', 'ACTIVE')] + [string] + $ICMPVSRResponse = 'PASSIVE', [Parameter()] [string] - $HTTPSRedirectURL, + $HTTPRedirectURL, + + [Parameter()] + [int]$TimeOut = 2, + + [Parameter()] + [int]$ClientTimeout, [Parameter()] - [ValidateSet('PASSIVE', 'ACTIVE')] [string] - $ICMPVSResponse = 'PASSIVE', + $BackupVServer, [Parameter()] - [int] - $Timeout, + [ValidateSet('ENABLED', 'DISABLED')] + [string]$RedirectPortRewrite = 'DISABLED', [Switch]$PassThru ) @@ -199,42 +218,35 @@ function New-NSLBVirtualServer { foreach ($item in $Name) { if ($PSCmdlet.ShouldProcess($item, 'Create Virtual Server')) { try { - if ($NonAddressable) { - $params = @{ - name = $item - comment = $comment - servicetype = $ServiceType - lbmethod = $LBMethod - icmpvsrresponse = $ICMPVSResponse - } - } else { - $params = @{ - name = $item - comment = $comment - servicetype = $ServiceType - ipv46 = $IPAddress - port = $Port - lbmethod = $LBMethod - icmpvsrresponse = $ICMPVSResponse - } + $params = @{ + name = $item + comment = $comment + servicetype = $ServiceType + ipv46 = $IPAddress + port = $Port + lbmethod = $LBMethod + icmpvsrresponse = $ICMPVSRResponse + redirectportrewrite = $RedirectPortRewrite } 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('HTTPRedirectURL')) { + $params.Add('redirurl', $HTTPRedirectURL) } - if ($PSBoundParameters.ContainsKey('Timeout')) { $params.Add('timeout', $Timeout) } - + if ($PSBoundParameters.ContainsKey('ClientTimeout')) { + $params.Add('clttimeout', $ClientTimeout) + } + 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 new file mode 100644 index 0000000..5b7c219 --- /dev/null +++ b/NetScaler/Public/New-NSResponderHTMLPage.ps1 @@ -0,0 +1,83 @@ +<# +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 New-NSResponderHTMLPage { + <# + .SYNOPSIS + Add Responder HTML page to NetScaler appliance. + + .DESCRIPTION + Add Responder HTML page to NetScaler appliance. + + .EXAMPLE + New-NSResponderHTMLPage -Name 'myrootCA' -Source 'http://somewebsite.com/somefile' -Comment 'Application XYZ page' + + Creates a Responder HTML page sourcing from a repo named 'http://somewebsite.com/somefile' into 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 + + .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. Also, check any firewall rules in between source and destination. + Minimum length = 1 + Maximum length = 2047 + + .PARAMETER Comment + Any comments to preserve information about the HTML page object. + Maximum length = 128 + + .PARAMETER Overwrite + Overwrites the existing file. + #> + + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [Parameter()] + [string]$Name, + + [Parameter()] + [string]$Source, + + [Parameter()] + [switch]$Overwrite = $false + ) + + begin { + _AssertSessionActive + } + + process { + if ($PSCmdlet.ShouldProcess($Name, 'Add a HTML Responder page')) { + try { + $params = @{ + src = $Source + name = $Name + overwrite = $Overwrite.ToBool() + } + $response = _InvokeNSRestApi -Session $Session -Method POST -Type responderhtmlpage -Payload $params -Action import + } catch { + throw $_ + } + } + } +} diff --git a/NetScaler/Public/New-NSResponderPolicy.ps1 b/NetScaler/Public/New-NSResponderPolicy.ps1 index 4230a46..60d0b7a 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,12 @@ 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. + .PARAMETER Passthru Return the newly created responder policy. #> @@ -53,12 +59,17 @@ function New-NSResponderPolicy { [string[]]$Name, [Parameter(Mandatory=$True)] - [string] - $Rule, + [string]$Rule, [Parameter(Mandatory=$True)] - [string] - $Action, + [string]$Action, + + [Parameter()] + [ValidateSet('NOOP','RESET','DROP')] + [string]$UndefinedAction = '', + + [Parameter()] + [string]$Comment, [Switch]$PassThru ) @@ -75,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-NSRewritePolicy.ps1 b/NetScaler/Public/New-NSRewritePolicy.ps1 index ba6e400..e54a14d 100644 --- a/NetScaler/Public/New-NSRewritePolicy.ps1 +++ b/NetScaler/Public/New-NSRewritePolicy.ps1 @@ -96,11 +96,11 @@ function New-NSRewritePolicy { if ($PSCmdlet.ShouldProcess($Item, 'Create rewrite policy')) { try { $params = @{ - name = $Item - action = $ActionName - comment = $Comment - logaction = $LogActionName - rule = $Rule + name = $Item + action = $ActionName + comment = $Comment + logaction = $LogActionName + rule = $Rule } _InvokeNSRestApi -Session $Session -Method POST -Type rewritepolicy -Payload $params -Action add diff --git a/NetScaler/Public/New-NSSSLProfile.ps1 b/NetScaler/Public/New-NSSSLProfile.ps1 index 9ae92b4..8402375 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" @@ -100,9 +104,6 @@ function New-NSSSLProfile { [ValidateSet('FrontEnd','BackEnd')] [string]$ProfileType, - [ValidateSet('ENABLED','DISABLED')] - [string]$SSL2, - [ValidateSet('ENABLED','DISABLED')] [string]$SSL3, @@ -142,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-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-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..bcc3966 --- /dev/null +++ b/NetScaler/Public/Remove-NSDnsNameServer.ps1 @@ -0,0 +1,104 @@ +<# +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 Remove-NSDnsNameServer { + <# + .SYNOPSIS + Add domain name server to NetScaler appliance. + + .DESCRIPTION + Add domain name server to NetScaler appliance. + + .EXAMPLE + Add-NSDnsNameServer -DNSServerIP '8.8.8.8' + + Adds DNS server IP 8.8.8.8 to NetScaler. + + .EXAMPLE + '2.2.2.2', '8.8.8.8' | Add-NSDnsNameServer -Session $session + + Adds DNS server IP 8.8.8.8 to 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 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 + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [parameter()] + [ValidateScript({$_ -match [IPAddress]$_ })] + [string[]]$IPAddress = (Read-Host -Prompt 'DNS server IP'), + + [string]$DNSVServerName = [string]::Empty + + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $IPAddress) { + if ($PSCmdlet.ShouldProcess($item, 'Add DNS server IP')) { + try { + + $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 $_ + } + } + } + } +} \ No newline at end of file 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-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 new file mode 100644 index 0000000..a5ec89d --- /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 + Unbinds a virtual server from a certificate certificate. + + .DESCRIPTION + Unbinds a virtual server from a certificate certificate. + + .EXAMPLE + Remove-NSLBSSLVirtualServerCertificateBinding -VirtualServerName 'vserver01' -Certificate 'cert' + + Unbinds the certificate 'cert' from 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-NSLBSSLVirtualServerCipherGroupBinding.ps1 b/NetScaler/Public/Remove-NSLBSSLVirtualServerCipherGroupBinding.ps1 new file mode 100644 index 0000000..6ffff58 --- /dev/null +++ b/NetScaler/Public/Remove-NSLBSSLVirtualServerCipherGroupBinding.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-NSLBSSLVirtualServerCipherGroupBinding { + <# + .SYNOPSIS + Unbinds a new load balancer cipher group binding. + + .DESCRIPTION + Unbinds a new load balancer cipher group binding. + + .EXAMPLE + Remove-NSLBSSLVirtualServerCipherGroupBinding -VirtualServerName 'vserver01' -Ciphername 'somecipher' + + Unbinds 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-NSLBSSLVirtualServerCipherGroupBinding -Session $Session -VirtualServerName $VirtualServerName + } + } catch { + throw $_ + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Remove-NSLBSSLVirtualServerCipherSuiteBinding.ps1 b/NetScaler/Public/Remove-NSLBSSLVirtualServerCipherSuiteBinding.ps1 new file mode 100644 index 0000000..bf9a63f --- /dev/null +++ b/NetScaler/Public/Remove-NSLBSSLVirtualServerCipherSuiteBinding.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-NSLBSSLVirtualServerCipherSuiteBinding { + <# + .SYNOPSIS + Unbinds a cipher suite from a virtual server + + .DESCRIPTION + Unbinds a cipher suite from a virtual server + + .EXAMPLE + Remove-NSLBSSLVirtualServerCipherSuiteBinding -VirtualServerName 'vserver01' -CipherName 'somecipher' + + Unbinds a cipher suite named 'somecipher' from the virtual server 'vserver01'. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VirtualServerName + Name of the SSL virtual server + + .PARAMETER CipherName + The name of the cipher group + + .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-NSLBSSLVirtualServerCipherSuiteBinding -Session $Session -VirtualServerName $VirtualServerName + } + } catch { + throw $_ + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Remove-NSLBService.ps1 b/NetScaler/Public/Remove-NSLBService.ps1 new file mode 100644 index 0000000..9b53050 --- /dev/null +++ b/NetScaler/Public/Remove-NSLBService.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 Remove-NSLBService { + <# + .SYNOPSIS + Removes the specified load balancer service object. + + .DESCRIPTION + Removes the specified load balancer service object. + + .EXAMPLE + Remove-NSLBService -Name 'service01' + + Removes the load balancer service named 'service01'. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER Name + The name or names of the load balancer service to get. + #> + [cmdletbinding()] + param( + $Session = $script:session, + + [parameter(ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName)] + [string[]]$Name = @(), + + [switch]$Force + ) + + begin { + _AssertSessionActive + $service = @() + } + + process { + foreach ($item in $Name) { + if ($Force -or $PSCmdlet.ShouldProcess($item, 'Delete Service')) { + try { + _InvokeNSRestApi -Session $Session -Method DELETE -Type service -Resource $item -Action delete + } catch { + throw $_ + } + } + } + } +} \ No newline at end of file diff --git a/NetScaler/Public/Remove-NSLBServiceGroupMemberBinding.ps1 b/NetScaler/Public/Remove-NSLBServiceGroupMemberBinding.ps1 new file mode 100644 index 0000000..73192ed --- /dev/null +++ b/NetScaler/Public/Remove-NSLBServiceGroupMemberBinding.ps1 @@ -0,0 +1,99 @@ +<# +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-NSLBServiceGroupMemberBinding { + <# + .SYNOPSIS + Disassociates a server from a service group. + + .DESCRIPTION + Disassociates a server from a service group. + + .EXAMPLE + Remove-NSLBServiceGroupMember -Name 'sg01' -ServerName 'server01' -Port 80 + + Disassociates server 'server01' from service group 'sg01' + + .EXAMPLE + $x = Remove-NSLBServiceGroupMember -Name 'sg01' -ServerName 'server01' -Port 80 -PassThru + + Disassociates server 'server01' with service group 'sg01' 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 Passthru + Return the service group binding object. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [parameter(Mandatory, ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName = $true)] + [string[]]$ServiceName, + + [Parameter(Mandatory)] + [string[]]$ServerName, + + [Parameter(Mandatory)] + [ValidateRange(1, 65535)] + [int]$Port, + + [switch]$PassThru + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $ServiceName) { + foreach ($member in $ServerName) { + if ($PSCmdlet.ShouldProcess($item, "Remove Service Group Member: $Member")) { + try { + $params = @{ + servicegroupname = $item + servername = $ServerName + port = $Port + } + + _InvokeNSRestApi -Session $Session -Method DELETE -Type servicegroup_servicegroupmember_binding -Resource $item -Arguments $params -Action delete + + if ($PSBoundParameters.ContainsKey('PassThru')) { + return Get-NSLBServiceGroupMemberBinding -Session $session -Name $item + } + } catch { + throw $_ + } + } + } + } + } +} \ No newline at end of file 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-NSLBVirtualServerResponderPolicyBinding.ps1 b/NetScaler/Public/Remove-NSLBVirtualServerResponderPolicyBinding.ps1 new file mode 100644 index 0000000..7a3594e --- /dev/null +++ b/NetScaler/Public/Remove-NSLBVirtualServerResponderPolicyBinding.ps1 @@ -0,0 +1,103 @@ +<# +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 Remove-NSLBVirtualServerResponderPolicyBinding { + <# + .SYNOPSIS + Adds a new load balancer responder policy binding. + + .DESCRIPTION + Adds a new load balancer responder policy binding. + + .EXAMPLE + Add-NSLBVirtualServerResponderPolicyBinding -VirtualServerName 'vserver01' -PolicyName 'pol01' -Bindpoint 'RESPONSE' -Priority '100' + + Bind the policy 'pol01' as a response policy with a priority of 100 to virtual server 'vserver01'. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER VirtualServerName + Name for the virtual server. Must begin with an ASCII alphanumeric or underscore (_) character, and must contain + only ASCII alphanumeric, underscore, hash (#), period (.), space, colon (:), at sign (@), equal sign (=), + and hyphen (-) characters. Can be changed after the virtual server is created. + + Minimum length = 1 + + .PARAMETER PolicyName + Name of the policy bound to the LB vserver. + + .PARAMETER Bindpoint + The bindpoint to which the policy is bound. + Possible values = REQUEST, RESPONSE + + .PARAMETER Priority + Policy priority. + + .PARAMETER Passthru + Return the load balancer server object. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Medium')] + param( + $Session = $script:session, + + [parameter(Mandatory=$True)] + [string] + $VirtualServerName = (Read-Host -Prompt 'LB virtual server name'), + + [parameter(Mandatory=$True)] + [string] + $PolicyName, + + [parameter()] + [ValidateSet('REQUEST', 'RESPONSE')] + [string] + $Bindpoint, + + [parameter(Mandatory=$True)] + [ValidateRange(1, 2147483647)] + [int] + $Priority, + + [Switch]$PassThru + ) + + begin { + _AssertSessionActive + } + + process { + if ($PSCmdlet.ShouldProcess($VirtualServerName, 'Add Virtual Server Binding')) { + try { + + $params = @{ + name = $VirtualServerName + policyname = $PolicyName + bindpoint = $Bindpoint + priority = $Priority + } + + _InvokeNSRestApi -Session $Session -Method DELETE -Type lbvserver_responderpolicy_binding -Resource $VirtualServerName -Arguments $params -Action delete + + if ($PSBoundParameters.ContainsKey('PassThru')) { + return Get-NSLBVirtualServerResponderPolicyBinding -Session $Session -Name $VirtualServerName + } + } catch { + throw $_ + } + } + } +} \ No newline at end of file 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-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-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..01435ef --- /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 + Removes an untagged/unbound VLAN from NetScaler appliance. + + .DESCRIPTION + Removes an untagged/unbound VLAN from NetScaler appliance. + + .EXAMPLE + Remove-NSVLAN -VLANID 150 + + Removes 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..a0856a5 --- /dev/null +++ b/NetScaler/Public/Remove-NSVLANInterfaceBinding.ps1 @@ -0,0 +1,78 @@ +<# +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 + Unbinds an interface from a vlan + + .DESCRIPTION + Unbinds an interface from a vlan + + .EXAMPLE + Remove-NSVLANInterfaceBinding -VLANID 150 -interface '0/1' -tagged + + Unbinds interface '0/1' from vlan 150 + + .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 = '0/1', + + [Switch]$Force + + ) + + begin { + _AssertSessionActive + } + + process { + + $params = @{ + id = $VLANID + ifnum = $Interface + } + + foreach ($item in $VLANID) { + 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 + } + 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..c746f60 --- /dev/null +++ b/NetScaler/Public/Set-NSLBMonitor.ps1 @@ -0,0 +1,451 @@ +<# +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')) { + $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-NSLBService.ps1 b/NetScaler/Public/Set-NSLBService.ps1 new file mode 100644 index 0000000..4e94eae --- /dev/null +++ b/NetScaler/Public/Set-NSLBService.ps1 @@ -0,0 +1,430 @@ +<# +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-NSLBService { + <# + .SYNOPSIS + Updates a new service to the loadbalancer. + + .DESCRIPTION + Updates a new service to the loadbalancer. + + .EXAMPLE + Set-NSLBService -Name 'service01' -ClientIP ENABLED + + Updates a new service called 'service01' by enabling ClientIP option + + .EXAMPLE + 'service01' | Set-NSLBService -ServiceType HTTP -Comment 'test service' + + Updates a new HTTP service called 'service01' with a comment. + + .EXAMPLE + Set-NSLBService -Name 'service01' -IPAddress 50.45.54.9 -State DISABLED -Verbose + + Updates a service (service01) by disabling it. The Name and IP must be specified. + + .PARAMETER Session + The NetScaler session object. + + .PARAMETER Name + The name of the service to create. + + .PARAMETER IPAddress + IP to assign to the service. Cannot be used in combination with the 'ServerName' option + Minimum length = 1 + + .PARAMETER State + Initial state of the service. Will only work if a name and ipaddress are specified in conjunction with the State. + Default value: ENABLED + Possible values = ENABLED, DISABLED + + .PARAMETER Cacheable + Use the transparent cache redirection virtual server to forward the request to the cache server. + Note: Do not set this parameter if you set the Cache Type. + Default value: NO + Possible values = YES, NO + + .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. + With the NO option, the appliance shows the service as UP at all times. + Default value: YES + Possible values = YES, NO + + .PARAMETER AppFlowLog + Enable logging of AppFlow information for the specified service. + Default value: ENABLED + Possible values = ENABLED, DISABLED + + .PARAMETER Comment + Any information about the service. + + .PARAMETER SureConnect + State of the SureConnect feature for the service. + Default value: OFF + Possible values = ON, OFF + + .PARAMETER SurgeProtection + Enable surge protection for the service. + Default value: OFF + 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. + 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. + 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 + is used as the source IP address to initiate server side connections. + Possible values = YES, NO + + .PARAMETER ClientKeepAlive + Enable client keep-alive for the service. + Possible values = YES, NO + + .PARAMETER TCPBuffering + Enable TCP buffering for the service. + Possible values = YES, NO + + .PARAMETER HTTPCompression + Enable compression for the specified service. + Possible values = YES, NO + + .PARAMETER ClientIP + Insert the Client IP header in requests forwarded to the service. + 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 + value set by the set ns config command is used as client's IP header name. + Minimum length = 1 + + .PARAMETER PathMonitor + Path monitoring for clustering. + Possible values = YES, NO + + .PARAMETER PathMonitorIndividual + Individual Path monitoring decisions. + Possible values = YES, NO + + .PARAMETER RTPSessionIDRemap + Enable RTSP session ID mapping for the service. + Default value: OFF + Possible values = ON, OFF + + .PARAMETER ServerID + 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 + + .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 + + .PARAMETER TCPProfileName + Name of the TCP profile that contains TCP configuration settings for the service. + Minimum length = 1 + Maximum length = 127 + + .PARAMETER HTTPProfileName + Name of the HTTP profile that contains HTTP configuration settings for the service. + Minimum length = 1 + Maximum length = 127 + + .PARAMETER NetProfile + Minimum length = 1 + Maximum length = 127 + .PARAMETER TrafficDomain + Integer value that uniquely identifies the traffic domain in which you want to configure the entity. If you do not specify an ID, the entity becomes part of the default traffic domain, which has an ID of 0. + Minimum value = 0 + Maximum value = 4094 + .PARAMETER ProcessLocal + By turning on this option packets destined to a service in a cluster will not under go any steering. Turn this option for single packet request response mode or when the upstream device is performing a proper RSS for connection based distribution. + Default value: DISABLED + Possible values = ENABLED, DISABLED + + .PARAMETER MonitorThreshold + 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 + + .PARAMETER MaxRequests + Maximum number of requests that can be sent on a persistent connection to the service. + Note: Connection requests beyond this value are rejected. + Minimum value = 0 + Maximum value = 65535 + + .PARAMETER MaxClients + Maximum number of simultaneous open connections for the service. + Minimum value = 0 + Maximum value = 4294967294 + + .PARAMETER ClientIdleTimeout + Time, in seconds, after which to terminate an idle client connection. + Minimum value = 0 + Maximum value = 31536000 + + .PARAMETER ServerIdleTimeout + Time, in seconds, after which to terminate an idle server connection. + Minimum value = 0 + Maximum value = 31536000 + + .PARAMETER Passthru + Return the newly created service group. + #> + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Low')] + param( + $Session = $script:session, + + [parameter(Mandatory, ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName = $true)] + [string[]]$Name = (Read-Host -Prompt 'LB service group name'), + + [parameter(ParameterSetName='IPAddress')] + [ValidateScript({$_ -match [IPAddress]$_ })] + [string]$IPAddress, + + [ValidateSet('ENABLED', 'DISABLED')] + [string]$State = 'ENABLED', + + [ValidateSet('NO', 'YES')] + [string]$Cacheable = 'NO', + + [ValidateRange(0, 65535)] + [int]$MaxRequests, + + [ValidateRange(0, 4294967294)] + [int]$MaxClients, + + [ValidateSet('NO', 'YES')] + [string]$HealthMonitor = 'YES', + + [ValidateSet('DISABLED', 'ENABLED')] + [string]$AppFlowLog = 'ENABLED', + + [ValidateLength(0, 256)] + [string]$Comment = [string]::Empty, + + [ValidateSet('ON', 'OFF')] + [string]$SureConnect = 'OFF', + + [ValidateSet('ON', 'OFF')] + [string]$SurgeProtection = 'OFF', + + [ValidateSet('YES','NO')] + [string]$UseProxyPort = 'YES', + + [ValidateSet('ENABLED','DISABLED')] + [string]$DownStateFlush = 'ENABLED', + + [ValidateSet('YES','NO')] + [string]$UseClientIP = 'NO', + + [string]$ClientIPHeader, + + [ValidateSet('YES','NO')] + [string]$ClientKeepAlive = 'NO', + + [ValidateSet('YES', 'NO')] + [string]$TCPBuffering = 'NO', + + [ValidateSet('YES', 'NO')] + [string]$HTTPCompression = 'YES', + + [ValidateSet('ENABLED','DISABLED')] + [string]$ClientIP = 'DISABLED', + + [ValidateSet('YES', 'NO')] + [string]$PathMonitor, + + [ValidateSet('YES', 'NO')] + [string]$PathMonitorIndividual, + + [ValidateSet('On', 'OFF')] + [string]$RTPSessionIDRemap = 'OFF', + + [ValidateRange(0, 4294967287)] + [int]$MaxBandwidthKbps, + + [ValidateSet('YES', 'NO')] + [string]$AccessDown = 'No', + + [string]$TCPProfileName, + + [string]$HTTPProfileName, + + [string]$NetProfileName, + + [ValidateRange(0, 4294967287)] + [int]$HashID, + + [string]$ProcessLocal, + + [ValidateRange(0, 65535)] + [int]$ServerID, + + [ValidateRange(0, 65535)] + [int]$MonitorThreshold, + + [ValidateRange(0, 31536000)] + [int]$ClientIdleTimeout = 180, + + [ValidateRange(0, 31536000)] + [int]$ServerIdleTimeout = 360, + + [Switch]$PassThru + ) + + begin { + _AssertSessionActive + } + + process { + foreach ($item in $Name) { + if ($PSCmdlet.ShouldProcess($item, 'Update Service')) { + try { + $params = @{ + name = $item + } + if ($PSBoundParameters.ContainsKey('Comment')) { + $params.Add('comment', $Comment) + } + 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('ipaddress', $IPAddress) + } + if ($PSBoundParameters.ContainsKey('HTTPCompression')) { + $params.Add('cmp', $HTTPCompression) + } + if ($PSBoundParameters.ContainsKey('ClientIPHeader')) { + $params.Add('cipheader', $ClientIPHeader) + } + if ($PSBoundParameters.ContainsKey('PathMonitor')) { + $params.Add('pathmonitor', $PathMonitor) + } + if ($PSBoundParameters.ContainsKey('PathMonitorIndv')) { + $params.Add('pathmonitorindv', $PathMonitorIndividual) + } + if ($PSBoundParameters.ContainsKey('RTPSessionIDRemap')) { + $params.Add('rtpsessionidremap', $RTPSessionIDRemap) + } + if ($PSBoundParameters.ContainsKey('ServerID')) { + $params.Add('serverid', $ServerID) + } + if ($PSBoundParameters.ContainsKey('MaxBandwidthKbps')) { + $params.Add('maxbandwidth', $MaxBandwidthKbps) + } + if ($PSBoundParameters.ContainsKey('AccessDown')) { + $params.Add('accessdown', $AccessDown) + } + 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('ProcessLocal')) { + $params.Add('processlocal', $ProcessLocal) + } + if ($PSBoundParameters.ContainsKey('MonitorThreshold')) { + $params.Add('monthreshold', $MonitorThreshold) + } + if ($PSBoundParameters.ContainsKey('MaxRequests')) { + $params.Add('maxreq', $MaxRequests) + } + if ($PSBoundParameters.ContainsKey('MaxClients')) { + $params.Add('maxclient', $MaxClients) + } + + _InvokeNSRestApi -Session $Session -Method PUT -Type service -Payload $params -Action update + + $params = @{ + name = $item + } + if ($State -eq "DISABLED") { + _InvokeNSRestApi -Session $Session -Method POST -Type service -Payload $params -Action disable + } else { + _InvokeNSRestApi -Session $Session -Method POST -Type service -Payload $params -Action enable + } + if ($PSBoundParameters.ContainsKey('PassThru')) { + return Get-NSLBService -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..414cee6 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, @@ -184,9 +201,18 @@ function Set-NSLBServiceGroup { $params = @{ servicegroupname = $item } + 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) } @@ -211,6 +237,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 +249,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..ab5ca4d 100644 --- a/NetScaler/Public/Set-NSLBVirtualServer.ps1 +++ b/NetScaler/Public/Set-NSLBVirtualServer.ps1 @@ -29,13 +29,13 @@ 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' -Force - - Sets the IP address for virtual server 'vserver01' to '11.11.11.11' and suppresses confirmation. + 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 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,29 @@ 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 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 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. @@ -66,13 +92,31 @@ 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, + + [ValidateSet('SOURCEIP', 'COOKIEINSERT', 'SSLSESSION', 'CUSTOMSERVERID', 'RULE', 'URLPASSIVE', 'DESTIP', 'SRCIPDESTIP', 'CALLID' ,'RTSPID', 'FIXSESSION', 'NONE')] + [string] + $PersistenceType, [ValidateScript({$_ -match [IPAddress]$_ })] [string]$IPAddress, + [string]$HttpRedirectURL, + [ValidateLength(0, 256)] - [string]$Comment = '', + [string]$Comment, + + [ValidateSet('PASSIVE', 'ACTIVE')] + [string]$ICMPVSRResponse, + + [int]$TimeOut, + + [int]$ClientTimeout, + + [string]$BackupVServer, + + [ValidateSet('ENABLED', 'DISABLED')] + [string]$RedirectPortRewrite, [Switch]$Force, @@ -89,17 +133,37 @@ function Set-NSLBVirtualServer { $params = @{ name = $item } + if ($PSBoundParameters.ContainsKey('TimeOut')) { + $params.Add('timeout', $TimeOut) + } + if ($PSBoundParameters.ContainsKey('ICMPVSRResponse')) { + $params.Add('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) } - - _InvokeNSRestApi -Session $Session -Method PUT -Type lbvserver -Payload $params -Action update + if ($PSBoundParameters.ContainsKey('HttpRedirectURL')) { + $params.Add('redirurl', $HttpRedirectURL) + } + 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')) { return Get-NSLBVirtualServer -Session $Session -Name $item diff --git a/NetScaler/Public/Set-NSNTPServer.ps1 b/NetScaler/Public/Set-NSNTPServer.ps1 new file mode 100644 index 0000000..aa7da72 --- /dev/null +++ b/NetScaler/Public/Set-NSNTPServer.ps1 @@ -0,0 +1,99 @@ +<# +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-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-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 new file mode 100644 index 0000000..a78d7ef --- /dev/null +++ b/NetScaler/Public/Set-NSResponderPolicy.ps1 @@ -0,0 +1,100 @@ +<# +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 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. + #> + [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()] + [ValidateSet('NOOP','RESET','DROP')] + [string]$UndefinedAction = '', + + [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 + undefaction = $UndefinedAction + } + _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 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 $_ + } + } + } + } +}