Skip to content

Commit 2e31107

Browse files
committed
Added Get-NSConfig : retrieve netscaler configuration (running or saved)
1 parent e399dc4 commit 2e31107

3 files changed

Lines changed: 67 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,6 @@ FakesAssemblies/
197197

198198
# Visual Studio 6 workspace options file
199199
*.opt
200+
201+
# Mac metadata
202+
.DS_Store

NetScaler/NetScaler.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ FunctionsToExport = @(
9999
'Enable-NSLBVirtualServer',
100100
'Enable-NSMode',
101101
'Get-NSAvailableTimeZone',
102+
'Get-NSConfig',
102103
'Get-NSFeature',
103104
'Get-NSHostname',
104105
'Get-NSLBMonitor',

NetScaler/Public/Get-NSConfig.ps1

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<#
2+
Copyright 2016 Dominique Broeglin
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 Get-NSConfig {
18+
<#
19+
.SYNOPSIS
20+
Gets the specified Netscaler configuration.
21+
22+
.DESCRIPTION
23+
Gets the specified Netscaler configuration. The returned configuration is an
24+
array of strings. Each string represents a configuration line. Comments, empty
25+
lines and the " Done" line are prunned.
26+
27+
.EXAMPLE
28+
Get-NSConfig
29+
30+
Get the running configuration.
31+
32+
.EXAMPLE
33+
Get-NSConfig -State saved
34+
35+
Get the saved configuration
36+
37+
.PARAMETER Session
38+
The NetScaler session object.
39+
40+
.PARAMETER State
41+
The state of the configuration that should be returned. Defaults to 'running'.
42+
#>
43+
[cmdletbinding()]
44+
param(
45+
$Session = $script:session,
46+
47+
[ValidateSet('running', 'saved')]
48+
[string]$State = 'running'
49+
)
50+
51+
begin {
52+
_AssertSessionActive
53+
}
54+
55+
process {
56+
if ($State -eq 'running') {
57+
$Config = (_InvokeNSRestApi -Session $Session -Method Get -Type nsrunningconfig -Action GetAll).nsrunningconfig.response
58+
} else {
59+
$Config = (_InvokeNSRestApi -Session $Session -Method Get -Type nssavedconfig -Action GetAll).nssavedconfig.textblob
60+
}
61+
$Config -Split '\n' | ? { $_ -and !($_ -match "^( Done| *#)") }
62+
}
63+
}

0 commit comments

Comments
 (0)