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