Skip to content

Commit 2396af2

Browse files
authored
Merge v1.3.0 from dev branch (#34)
* New public script / function files Adding new functions to perform queries for AAA user, AAA groups, AAA user bindings, and AAA group bindings. * Update to manifest exported functions list Added new functions Get-AAAGroup, Get-AAAGroupBinding, Get-AAAUser, and Get-AAAGroupBinding to the exported functions list in the module manifest. * Added peristence type and persistence timeout * Added HTTP request and expected response codes parameters * Binding weight is invalid for Service Groups. Moved it to only be used if we are binding a Service. * Added functions to add and get Content Switching virtual server responder policy bindings. * Function to create a new Content Switching virtual server * Functions to add and get SSL virtual server certificate bindings * Add and get load balancing virtual server rewrite policy bindings * Get and update SSL virtual server * Add a monitor to a service group * Get service group monitor bindings * Updated PR files per recommendations Made requested changes to functions Get-NSAAAGroup, Get-NSAAAGroupBinding, Get-NSAAAUser, and Get-NSAAAUserBinding. * Move new functions to Public folder. * Update changelog with new functions * update changelog * Install any needed modules from PSGallery explicitly * Add Pester tests for module help * Exclude Pester tests from being loaded by module * Add psake task `Pester-Module` to run Pester tests on module functions Existing psake task 'Pester' has been renamed to 'Pester-Meta' to reflect that it is intended to test meta information about the module. * Add Pester tests for Connect-NetScaler * Fixed Set-NSHostname and Set-NSTimeZone update actions Fixes #16 * Fixed ConvertTo-Json depth in PowerShell 5.1 Fixes #17 * Fixed filename rewrite issue in Add-NSSystemFile Fixes #18 * Fixed certificate import without private key in Add-NSCertKeyPair Fixes #21 Fixes #22 * Modified New-NSLBMonitor to support custom monitor properties Fixes #19 * Add missing help examples * Exclude -Confirm and -WhatIf parameters from validation. * Add stub test to validate all functions have associated Pester tests. Leaving this commented out for now until tests are written for existing functions * Fix typo in comment-based help for parameter name * Add remarks to example * Change name of test * Fixed comment-based help * Corrected typos * Added remarks to examples * Added missing parameters descriptions * Reorganize Pester tests * Store mock objects separately so they can be reused across test scripts * Added 32 additional commands Modified Get-NSLBServiceGroupMonitorBinding to support filtering by monitor name Added -Force parameter to Add-NSLBSSLVirtualServerCertificateBinding to suppress confirmation Added private _AssertNSVersion to enforce particular versioned APIs Fixed _InvokeNSRestApiGet to filter collections Fixed bug in Add-NSDnsNameServer where DNSVServerName could not be blank * Fixes update action in Set-NSLBSSLVirtualServerProfile for v11.1 compatibility * Adds Get-NSTimeZone and additional help tests Fixes incorrect help command names
1 parent 4f11097 commit 2396af2

94 files changed

Lines changed: 5004 additions & 170 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,61 @@
11
## 1.3.0 (unreleased)
2-
-
2+
* Features
3+
* Added Add-NSCSVirtualServerResponderPolicyBinding (via @rokett)
4+
* Added Add-NSLBSSLVirtualServerCertificateBinding (via @rokett)
5+
* Added Add-NSLBVirtualServerRewritePolicyBinding (via @rokett)
6+
* Added Get-NSAAAGroup (via @psminion)
7+
* Added Get-NSAAAGroupBinding (via @psminion)
8+
* Added Get-NSAAAUser (via @psminion)
9+
* Added Get-NSAAAUserBinding (via @psminion)
10+
* Added Get-NSCSVirtualServerResponderPolicyBinding (via @rokett)
11+
* Added Get-NSLBServiceGroupMonitorBinding (via @rokett)
12+
* Added Get-NSLBSSLVirtualServer (via @rokett)
13+
* Added Get-NSLBSSLVirtualServerCertificateBinding (via @rokett)
14+
* Added Get-NSLBVirtualServerRewritePolicyBinding (via @rokett)
15+
* Added New-NSCSVirtualServer (via @rokett)
16+
* Added New-NSLBServiceGroupMonitor (via @rokett)
17+
* Added Set-NSLBSSLVirtualServer (via @rokett)
18+
* Added Get-NSVersion (via @iainbrighton)
19+
* Added Get-NSDnsNameServer (via @iainbrighton)
20+
* Added Get-NSDnsSuffix, Add-NSDnsSuffix and Remove-NSDnsSuffix (via @iainbrighton)
21+
* Added Get-NSSSLCertificateLink, Add-NSSSLCertificateLink and Remove-NSSSLCertificateLink (via @iainbrighton)
22+
* Added Get-NSSSLProfile, New-NSSSLProfile, Set-NSSSLProfile and Remove-NSSSLProfile (via @iainbrighton)
23+
* Added Add-NSLBServiceGroupMonitorBinding and Remove-NSLBServiceGroupMonitorBinding (via @iainbrighton)
24+
* Added Get-NSLBSSLVirtualServerProfile, Set-NSLBSSLVirtualServerProfile and Remove-NSLBSSLVirtualServerProfile (via @iainbrighton)
25+
* Added Get-NSLDAPAuthenticationServer, New-NSLDAPAuthenticationServer and Remove-NSLDAPAuthenticationServer (via @iainbrighton)
26+
* Added Get-NSLDAPAuthenticationPolicy, New-NSLDAPAuthenticationPolicy and Remove-NSLDAPAuthenticationPolicy (via @iainbrighton
27+
* Added New-NSVPNVirtualServer (via @iainbrighton)
28+
* Added Get-NSVPNVirtualServerBinding and Add-NSVPNVirtualServerBinding (via @iainbrighton)
29+
* Added Get-NSVPNVirtualServerTheme and Set-NSVPNVirtualServerTheme (via @iainbrighton)
30+
* Added New-NSVPNSessionPolicy and Remove-NSVPNSessionPolicy (via @iainbrighton)
31+
* Added New-NSVPNSessionProfile and Remove-NSVPNSessionProfile (via @iainbrighton)
32+
* Added Get-NSTimeZone (via @iainbrighton)
33+
34+
* Improvements
35+
* Modified New-NSLBMonitor allow setting HTTP request and expected response codes parameters (via @rokett)
36+
* Modified New-NSLBVirtualServer to allow setting PersistenceType and PersistenceTimeout parameters (via @rokett)
37+
* Modified New-NSLBMonitor to support custom monitor properties (via @iainbrighton)
38+
* Modified Get-NSLBServiceGroupMonitorBinding to support filtering by monitor name (via @iainbrighton)
39+
* Added -Force parameter to Add-NSLBSSLVirtualServerCertificateBinding to suppress confirmation (via @iainbrighton)
40+
* Added private _AssertNSVersion to enforce particular versioned APIs, e.g. Get-NSVPNVirtualServerTheme (via @iainbrighton)
41+
* Modified Set-NSTimeZone to accept pipeline input and return just the configured timezone (via @iainbrighton)
42+
* Added additional help tests and fixed incorrect help examples/commands (via @iainbrighton)
43+
44+
* Bug fixes
45+
* Fixed bug in Add-NSLBVirtualServerBinding where weight was improperly being added when binding to a service group. (via @rokett)
46+
* Fixed Set-NSHostname and Set-NSTimeZone update actions (via @iainbrighton)
47+
* Fixed ConvertTo-Json depth in PowerShell 5.1 (via @iainbrighton)
48+
* Fixed filename rewrite issue in Add-NSSystemFile (via @iainbrighton)
49+
* Fixed certificate import without private key in Add-NSCertKeyPair (via @iainbrighton)
50+
* Fixed comment-based help (via @devblackops)
51+
* Fixed _InvokeNSRestApiGet to filter collections (via @iainbrighton)
52+
* Fixed bug in Add-NSDnsNameServer where DNSVServerName could not be blank (via @iainbrighton)
353

454
## 1.2.0 (2016-04-19)
555
- Added Invoke-Nitro to wrap direct calls to _InvokeNSRestApi
656
- Added Get-NSConfig : retrieve NetScaler configuration (running or saved)
757
- Added Get/New/Set/Remove-NSResponderAction
8-
- Modified Get-NSLBMonitor, Get-NSLBServer, Get-NSLBServiceGroup to only return
58+
- Modified Get-NSLBMonitor, Get-NSLBServer, Get-NSLBServiceGroup to only return
959
resources if there are resources to return.
1060

1161
## 1.1.3 (2016-04-03)
@@ -20,4 +70,4 @@
2070
- Correct typo in Install-NSLicense
2171
- Correct typo in New-NSLBServiceGroup/Set-NSLBServiceGroup
2272
- Add -Force and -PassThru to Set-NSTimeZone
23-
- Allow any filepath when installing NS license in Install-NSLicense
73+
- Allow any filepath when installing NS license in Install-NSLicense

NetScaler/NetScaler.psd1

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,19 @@ PowerShellVersion = '3.0'
6868
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
6969
FunctionsToExport = @(
7070
'Add-NSCertKeyPair',
71+
'Add-NSCSVirtualServerResponderPolicyBinding',
7172
'Add-NSDnsNameServer',
73+
'Add-NSDnsSuffix',
7274
'Add-NSIPResource',
73-
'Add-NSLBVirtualServerBinding'
75+
'Add-NSLBServiceGroupMonitorBinding',
76+
'Add-NSLBSSLVirtualServerCertificateBinding',
77+
'Add-NSLBVirtualServerBinding',
78+
'Add-NSLBVirtualServerRewritePolicyBinding',
7479
'Add-NSRSAKey',
7580
'Add-NSServerCertificate',
81+
'Add-NSSSLCertificateLink',
7682
'Add-NSSystemFile',
83+
'Add-NSVPNVirtualServerBinding',
7784
'Clear-NSConfig',
7885
'Connect-NetScaler',
7986
'Disable-NSFeature',
@@ -87,12 +94,19 @@ FunctionsToExport = @(
8794
'Enable-NSLBServer',
8895
'Enable-NSLBVirtualServer',
8996
'Enable-NSMode',
97+
'Get-NSAAAGroup',
98+
'Get-NSAAAGroupBinding',
99+
'Get-NSAAAUser',
100+
'Get-NSAAAUserBinding',
90101
'Get-NSAAAVirtualServer',
91102
'Get-NSAvailableTimeZone',
92103
'Get-NSConfig',
93104
'Get-NSCSAction',
94105
'Get-NSCSPolicy',
95106
'Get-NSCSVirtualServer',
107+
'Get-NSCSVirtualServerResponderPolicyBinding',
108+
'Get-NSDnsNameServer',
109+
'Get-NSDnsSuffix',
96110
'Get-NSFeature',
97111
'Get-NSHostname',
98112
'Get-NSIPResource',
@@ -102,9 +116,16 @@ FunctionsToExport = @(
102116
'Get-NSLBServer',
103117
'Get-NSLBServiceGroup',
104118
'Get-NSLBServiceGroupMemberBinding',
119+
'Get-NSLBServiceGroupMonitorBinding',
120+
'Get-NSLBSSLVirtualServer',
121+
'Get-NSLBSSLVirtualServerCertificateBinding',
122+
'Get-NSLBSSLVirtualServerProfile',
105123
'Get-NSLBStat',
106124
'Get-NSLBVirtualServer',
107125
'Get-NSLBVirtualServerBinding',
126+
'Get-NSLBVirtualServerRewritePolicyBinding',
127+
'Get-NSLDAPAuthenticationPolicy',
128+
'Get-NSLDAPAuthenticationServer',
108129
'Get-NSResponderAction',
109130
'Get-NSResponderPolicy',
110131
'Get-NSRewriteAction',
@@ -114,36 +135,63 @@ FunctionsToExport = @(
114135
'Get-NSSAMLAuthenticationPolicy',
115136
'Get-NSSAMLAuthenticationServer',
116137
'Get-NSSSLCertificate',
138+
'Get-NSSSLCertificateLink',
139+
'Get-NSSSLProfile',
117140
'Get-NSSystemFile',
141+
'Get-NSTimeZone',
142+
'Get-NSVersion',
118143
'Get-NSVPNServer',
119144
'Get-NSVPNSessionPolicy',
120145
'Get-NSVPNSessionProfile',
121146
'Get-NSVPNVirtualServer',
147+
'Get-NSVPNVirtualServerBinding',
148+
'Get-NSVPNVirtualServerTheme',
122149
'Install-NSLicense',
123150
'Invoke-Nitro',
151+
'New-NSCSVirtualServer',
124152
'New-NSKCDAccount',
125153
'New-NSLBMonitor',
126154
'New-NSLBServer',
127155
'New-NSLBServiceGroup',
128156
'New-NSLBServiceGroupMember',
157+
'New-NSLBServiceGroupMonitor',
129158
'New-NSLBVirtualServer',
159+
'New-NSLDAPAuthenticationPolicy',
160+
'New-NSLDAPAuthenticationServer',
130161
'New-NSNTPServer',
131162
'New-NSResponderAction',
132163
'New-NSNTPServer',
164+
'New-NSSSLProfile',
165+
'New-NSVPNSessionPolicy',
166+
'New-NSVPNSessionProfile',
167+
'New-NSVPNVirtualServer',
168+
'Remove-NSDnsSuffix',
133169
'Remove-NSLBMonitor',
134170
'Remove-NSLBServer',
135171
'Remove-NSLBServiceGroup',
172+
'Remove-NSLBServiceGroupMonitorBinding',
136173
'Remove-NSLBVirtualServer',
137174
'Remove-NSLBVirtualServerBinding',
175+
'Remove-NSLBSSLVirtualServerProfile',
176+
'Remove-NSLDAPAuthenticationPolicy',
177+
'Remove-NSLDAPAuthenticationServer',
138178
'Remove-NSResponderAction',
179+
'Remove-NSSSLCertificateLink',
180+
'Remove-NSSSLProfile',
181+
'Remove-NSVPNSessionPolicy',
182+
'Remove-NSVPNSessionProfile',
139183
'Restart-NetScaler',
140184
'Save-NSConfig',
141185
'Set-NSHostname',
142186
'Set-NSLBServer',
143187
'Set-NSLBServiceGroup',
188+
'Set-NSLBSSLVirtualServer',
189+
'Set-NSLBSSLVirtualServerProfile',
144190
'Set-NSLBVirtualServer',
145191
'Set-NSResponderAction',
146-
'Set-NSTimeZone'
192+
'Set-NSSSLProfile',
193+
'Set-NSTimeZone',
194+
'Set-NSVPNVirtualServerTheme'
147195
)
148196

149197
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
@@ -185,14 +233,14 @@ PrivateData = @{
185233
ReleaseNotes = '- Added Invoke-Nitro to wrap direct calls to _InvokeNSRestApi
186234
- Added Get-NSConfig to retrieve NetScaler configuration (running or saved)
187235
- Added Get/New/Set/Remove-NSResponderAction
188-
- Modified Get-NSLBMonitor, Get-NSLBServer, Get-NSLBServiceGroup to only return
236+
- Modified Get-NSLBMonitor, Get-NSLBServer, Get-NSLBServiceGroup to only return
189237
resources if there are resources to return.'
190238

191239
# External dependent modules of this module
192240
# ExternalModuleDependencies = ''
193241

194242
} # End of PSData hashtable
195-
243+
196244
} # End of PrivateData hashtable
197245

198246
# HelpInfo URI of this module

NetScaler/NetScaler.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ $script:protocol = $null
2727
#[System.Reflection.Assembly]::LoadFile($dll2)
2828

2929
# Load public functions
30-
$publicFunctions = Get-ChildItem -Path "$PSScriptRoot\Public" -Recurse -Include *.ps1
30+
$publicFunctions = Get-ChildItem -Path "$PSScriptRoot\Public" -Recurse -Include *.ps1 -Exclude *.tests.ps1
3131
foreach ($function in $publicFunctions) {
3232
. $function.FullName
3333
}
3434

3535
# Load private functions
36-
$privateFunctions = Get-ChildItem -Path "$PSScriptRoot\Private" -Recurse -Include *.ps1
36+
$privateFunctions = Get-ChildItem -Path "$PSScriptRoot\Private" -Recurse -Include *.ps1 -Exclude *.tests.ps1
3737
foreach ($function in $privateFunctions) {
3838
. $function.FullName
3939
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<#
2+
Copyright 2016 Iain Brighton
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 _AssertNSVersion {
18+
<#
19+
.SYNOPSIS
20+
Ensures that the NetScaler appliance's version meets the specified minimum version.
21+
22+
.DESCRIPTION
23+
Ensures that the NetScaler appliance's version meets the specified minimum version.
24+
25+
.PARAMETER Session
26+
An existing custom NetScaler Web Request Session object returned by Connect-NetScaler.
27+
28+
.PARAMETER MinimumVersion
29+
Specifies the minimum version of NetScaler is required.
30+
31+
.EXAMPLE
32+
_AssertNSVersion -Session $session -MinimumVersion '11.0'
33+
34+
Ensure that the current session is a NetScaler 11.0 or later appliance.
35+
#>
36+
[cmdletbinding()]
37+
param (
38+
$Session = $script:session,
39+
40+
[parameter(Mandatory, ValueFromPipeline)]
41+
[System.Version]$MinimumVersion
42+
)
43+
44+
process {
45+
$nsVersion = Get-NSVersion -Session $Session
46+
if ($nsVersion.Version -lt $MinimumVersion) {
47+
$errorMessage = 'Netscaler version "{0}" is unsupported. Version "{1}" or later is required for this operation.'
48+
throw ($errorMessage -f $nsVersion.Version, $MinimumVersion)
49+
}
50+
}
51+
}

NetScaler/Private/_InvokeNSRestApi.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
function _InvokeNSRestApi {
22
<#
33
.SYNOPSIS
4-
Invoke NetScaler NITRO REST API
4+
Invoke NetScaler NITRO REST API
55
.DESCRIPTION
6-
Invoke NetScaler NITRO REST API
6+
Invoke NetScaler NITRO REST API
77
.PARAMETER Session
88
An existing custom NetScaler Web Request Session object returned by Connect-NetScaler
99
.PARAMETER Method
@@ -42,7 +42,7 @@ function _InvokeNSRestApi {
4242
[Parameter(Mandatory)]
4343
[string]$Type,
4444

45-
[string]$Resource,
45+
[string]$Resource,
4646

4747
[string]$Action,
4848

@@ -61,13 +61,13 @@ function _InvokeNSRestApi {
6161
[ValidateSet('EXIT', 'CONTINUE', 'ROLLBACK')]
6262
[string]$OnErrorAction = 'EXIT'
6363
)
64-
64+
6565
if ($Stat) {
6666
$uri = "$($Script:protocol)://$($Session.Endpoint)/nitro/v1/stat/$Type"
6767
} else {
6868
$uri = "$($Script:protocol)://$($Session.Endpoint)/nitro/v1/config/$Type"
6969
}
70-
70+
7171
if (-not [string]::IsNullOrEmpty($Resource)) {
7272
$uri += "/$Resource"
7373
}
@@ -120,7 +120,7 @@ function _InvokeNSRestApi {
120120
$hashtablePayload = @{}
121121
$hashtablePayload.'params' = @{'warning' = $warning; 'onerror' = $OnErrorAction; <#"action"=$Action#>}
122122
$hashtablePayload.$Type = $Payload
123-
$jsonPayload = ConvertTo-Json -InputObject $hashtablePayload -Depth ([int]::MaxValue)
123+
$jsonPayload = ConvertTo-Json -InputObject $hashtablePayload -Depth 100
124124
Write-Verbose -Message "JSON Payload:`n$jsonPayload"
125125
}
126126

@@ -136,13 +136,13 @@ function _InvokeNSRestApi {
136136
ErrorVariable = 'restError'
137137
Verbose = $false
138138
}
139-
139+
140140
if ($Method -ne 'GET') {
141141
$restParams.Add('Body', $jsonPayload)
142142
}
143143

144144
$response = Invoke-RestMethod @restParams
145-
145+
146146
if ($response) {
147147
if ($response.severity -eq 'ERROR') {
148148
throw "Error. See response: `n$($response | Format-List -Property * | Out-String)"

NetScaler/Private/_InvokeNSRestApiGet.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function _InvokeNSRestApiGet {
22
<#
33
.SYNOPSIS
4-
Invoke NetScaler NITRO REST API GET method
4+
Invoke NetScaler NITRO REST API GET method
55
66
.DESCRIPTION
77
Invoke NetScaler NITRO REST API GET method
@@ -14,32 +14,32 @@ function _InvokeNSRestApiGet {
1414
1515
.PARAMETER Name
1616
The name or names of the NS appliance resources.
17-
17+
1818
.PARAMETER Filters
1919
A Hashtable of search filter values.
20-
20+
2121
.EXAMPLE
2222
TODO
23-
24-
.OUTPUTS
23+
24+
.OUTPUTS
2525
PSCustomObject that represents the JSON response content. This object can be manipulated using the ConvertTo-Json Cmdlet.
2626
#>
2727
[CmdletBinding()]
2828
param (
2929
[Parameter(Mandatory)]
3030
[PSObject]$Session,
31-
31+
3232
[parameter(ValueFromPipeline = $true, Position = 0, ValueFromPipelineByPropertyName)]
3333
[string[]]$Name = @(),
3434

3535
[string]$Type,
36-
36+
3737
[Hashtable]$Filters = @{}
3838
)
3939

4040
if ($Name.Count -gt 0) {
4141
foreach ($item in $Name) {
42-
$response = _InvokeNSRestApi -Session $Session -Method Get -Type $Type -Resource $item -Action Get
42+
$response = _InvokeNSRestApi -Session $Session -Method Get -Type $Type -Resource $item -Action Get -Filters $Filters
4343
if ($response.errorcode -ne 0) { throw $response }
4444
if ($Response.psobject.properties.name -contains $Type) {
4545
$response.$Type
@@ -52,4 +52,4 @@ function _InvokeNSRestApiGet {
5252
$response.$Type
5353
}
5454
}
55-
}
55+
}

0 commit comments

Comments
 (0)