1+ <#
2+ Copyright 2015 Brandon Olin
3+
4+ Licensed under the Apache License, Version 2.0 (the "License");
5+ you may not use this file except in compliance with the License.
6+ You may obtain a copy of the License at
7+
8+ http://www.apache.org/licenses/LICENSE-2.0
9+
10+ Unless required by applicable law or agreed to in writing, software
11+ distributed under the License is distributed on an "AS IS" BASIS,
12+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ See the License for the specific language governing permissions and
14+ limitations under the License.
15+ #>
16+
17+ function Add-NSLBVirtualServerResponderPolicyBinding {
18+ <#
19+ . SYNOPSIS
20+ Adds a new load balancer responder policy binding.
21+
22+ . DESCRIPTION
23+ Adds a new load balancer responder policy binding.
24+
25+ . EXAMPLE
26+ Add-NSLBVirtualServerResponderPolicyBinding -VirtualServerName 'vserver01' -PolicyName 'pol01' -Bindpoint 'RESPONSE' -Priority '100'
27+
28+ Bind the policy 'pol01' as a response policy with a priority of 100 to virtual server 'vserver01'.
29+
30+ . PARAMETER Session
31+ The NetScaler session object.
32+
33+ . PARAMETER VirtualServerName
34+ Name for the virtual server. Must begin with an ASCII alphanumeric or underscore (_) character, and must contain
35+ only ASCII alphanumeric, underscore, hash (#), period (.), space, colon (:), at sign (@), equal sign (=),
36+ and hyphen (-) characters. Can be changed after the virtual server is created.
37+
38+ Minimum length = 1
39+
40+ . PARAMETER PolicyName
41+ Name of the policy bound to the LB vserver.
42+
43+ . PARAMETER Bindpoint
44+ The bindpoint to which the policy is bound.
45+ Possible values = REQUEST, RESPONSE
46+
47+ . PARAMETER Priority
48+ Policy priority.
49+
50+ . PARAMETER Passthru
51+ Return the load balancer server object.
52+ #>
53+ [cmdletbinding (SupportsShouldProcess = $true , ConfirmImpact = ' Medium' )]
54+ param (
55+ $Session = $script :session ,
56+
57+ [parameter (Mandatory = $True )]
58+ [string ]
59+ $VirtualServerName = (Read-Host - Prompt ' LB virtual server name' ),
60+
61+ [parameter (Mandatory = $True )]
62+ [string ]
63+ $PolicyName ,
64+
65+ [parameter (Mandatory = $True )]
66+ [ValidateSet (' REQUEST' , ' RESPONSE' )]
67+ [string ]
68+ $Bindpoint ,
69+
70+ [parameter (Mandatory = $True )]
71+ [ValidateRange (1 , 2147483647 )]
72+ [int ]
73+ $Priority ,
74+
75+ [Switch ]$PassThru
76+ )
77+
78+ begin {
79+ _AssertSessionActive
80+ }
81+
82+ process {
83+ if ($PSCmdlet.ShouldProcess ($VirtualServerName , ' Add Virtual Server Binding' )) {
84+ try {
85+
86+ $params = @ {
87+ name = $VirtualServerName
88+ policyname = $PolicyName
89+ bindpoint = $Bindpoint
90+ priority = $Priority
91+ }
92+
93+ _InvokeNSRestApi - Session $Session - Method PUT - Type lbvserver_responderpolicy_binding - Payload $params
94+
95+ if ($PSBoundParameters.ContainsKey (' PassThru' )) {
96+ return Get-NSLBVirtualServerResponderPolicyBinding - Session $Session - Name $VirtualServerName
97+ }
98+ } catch {
99+ throw $_
100+ }
101+ }
102+ }
103+ }
0 commit comments