Skip to content

Commit f3edc91

Browse files
committed
Priority Assignment
Update cmdlet to assign the Priority for the Policy Binding to be 10 points higher than the current max Priority.
1 parent 28ef31e commit f3edc91

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

NetScaler/Public/Add-NSCSVirtualServerPolicyBinding.ps1

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,19 @@ function Add-NSCSVirtualServerPolicyBinding {
7777
process {
7878
if ($PSCmdlet.ShouldProcess($Name, 'Add Content Switching Virtual Server Binding')) {
7979
try {
80-
if ($Priority) {
81-
$params = @{
82-
name = $Name
83-
policyname = $PolicyName
84-
targetlbvserver = $TargetLBVServer
85-
priority = $Priority
86-
}
87-
} else {
88-
$params = @{
89-
name = $Name
90-
policyname = $PolicyName
91-
targetlbvserver = $TargetLBVServer
92-
}
80+
if (-not $Priority) {
81+
# No priority was passed so find the highest currently used and add 10 to it
82+
$CSP = Get-NSCSVirtualServerPolicyBinding $Name | Sort-Object Priority -Descending | Select-Object -First 1
83+
$Priority = [double]$CSP.Priority + 10
9384
}
94-
85+
86+
$params = @{
87+
name = $Name
88+
policyname = $PolicyName
89+
targetlbvserver = $TargetLBVServer
90+
priority = $Priority
91+
}
92+
9593
_InvokeNSRestApi -Session $Session -Method PUT -Type csvserver_cspolicy_binding -Payload $params
9694

9795
if ($PSBoundParameters.ContainsKey('PassThru')) {

0 commit comments

Comments
 (0)