forked from cstalhood/Get-ADCVServerConfig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-ADCVServerConfig.ps1
2232 lines (1878 loc) · 120 KB
/
Get-ADCVServerConfig.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Citrix NetScaler ADC Virtual Server Configuration Extractor
# Note: This script works on Windows 10, but the regex match group commands fail on Windows 7
param (
# Full path to source config file saved from NetScaler (System > Diagnostics > Running Configuration)
# If set to "", then the script will prompt for the file.
[string]$configFile = "",
#$configFile = "$env:userprofile\Downloads\nsrunning.conf"
# Name of vServer - or VIP - case insensitive
# Partial match supported - if more than one match, the script will prompt for a selection. Set it to "" to list all vServers.
# If vserver name is exact match for one vserver, that vserver will be used, even if it's a substring match for another vserver
[string]$vserver = "",
# Optional filename to save output - file will be overwritten
# If you intend to batch import to NetScaler, then no spaces or capital letters in the file name.
# If set to "screen", then output will go to screen.
# If set to "", then the script will prompt for a file. Clicking cancel will output to the screen.
#$outputFile = ""
#$outputFile = "screen"
[string]$outputFile = "$env:userprofile\Downloads\nsconfig.conf",
# Optional text editor to open saved output file - text editor should handle UNIX line endings (e.g. Wordpad or Notepad++)
[string]$textEditor = "c:\Program Files (x86)\Notepad++\notepad++.exe",
# Optional get CSW vserver Binds for selected LB and/or VPN virtual server
[switch]$cswBind
#[switch]$cswBind = $true
)
# Change Log
# ----------
# 2018 Nov 5 - check text editor existince (h/t Bjørn-Kåre Flister)
# 2018 Nov 5 - switch to extract CS vServer for selected LB/VPN/AAA vServer (h/t Bjørn-Kåre Flister)
# 2018 Sep 19 - fixed SAML Policy and SAML Action
# 2018 Sep 11 - parameterized the script, fixed specified vServer
# 2018 July 22 - added ICA Parameters to VPN Global Settings
# 2018 July 18 - added preauthentication policy, added AlwaysOn profile
# 2018 July 12 - added two levels of nFactor NextFactor extraction
# 2018 July 8 - added DNS configuration to every extraction
# 2018 July 7 - added GSLB Sites and rpcNodes
# 2018 July 4 - extract local LB VIPs from Session Action URLs (e.g. StoreFront URL to local LB VIP)
# 2018 July 3 - extract DNS vServers from "set vpn parameter" and Session Actions
# 2018 July 3 - added "*" to select all vServers
# 2018 July 3 - updated for 12.1 (SSL Log Profile, IP Set, Analytics Profile)
# 2018 Jan 23 - skip gobal cache settings if cache feature is not enabled
# 2018 Jan 4 - Sirius' Mark Scott added code to browse to open and save files. Added kcdaccounts to extraction.
# Start of script code
cls
# Function to prompt the user for a NetScaler config file.
# The NetScaler config file can be found in the System > Diagnostics > Running Configuration location in the GUI
Function Get-InputFile($initialDirectory)
{
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.Title = "Open NetScaler Config"
$OpenFileDialog.initialDirectory = $initialDirectory
$OpenFileDialog.filter = "NetScaler Config (*.conf)| *.conf|All files (*.*)|*.*"
$OpenFileDialog.ShowDialog() | Out-Null
$OpenFileDialog.filename
}
# Function to prompt the user to save the output file
Function Get-OutputFile($initialDirectory)
{
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
$SaveFileDialog = New-Object System.Windows.Forms.SaveFileDialog
$SaveFileDialog.Title = "Save Extracted Config"
$SaveFileDialog.initialDirectory = $initialDirectory
$SaveFileDialog.filter = "NetScaler Config File (*.conf)| *.conf|All files (*.*)|*.*"
$SaveFileDialog.ShowDialog() | Out-Null
$SaveFileDialog.filename
}
# Run the Get-InputFile function to ask the user for the NetScaler config file
if (!$configFile) { $configFile = Get-InputFile $inputfile }
"Loading config file $configFile ...`n"
$config = ""
$config = Get-Content $configFile -ErrorAction Stop
function addNSObject ($NSObjectType, $NSObjectName) {
if (!$NSObjectName) { return }
# write-host $NSObjectType $NSObjectName #Debug
if (!$nsObjects.$NSObjectType) { $nsObjects.$NSObjectType = @()}
$tempObjects = $nsObjects.$NSObjectType
$nsObjects.$NSObjectType += $NSObjectName
$nsObjects.$NSObjectType = @($nsObjects.$NSObjectType | Select-Object -Unique)
# Check if anything was added and display - exit function if nothing new
$newObjects =@()
$newObjects = Compare-Object $tempObjects $nsObjects.$NSObjectType
if (!$newObjects) {return}
# Display progress
foreach ($newObject in $newObjects) {
write-host (("Found {0,-25} " -f $NSObjectType) + $newObject.InputObject )
#write-host ("In " + $timer.ElapsedMilliseconds + " ms, found $NSObjectType`t " + $newObject.InputObject)
#$timer.Stop()
#$timer.Restart()
}
# Get Filtered Config for the object being added to check for policy sub-objects
# Don't match "-" to prevent "add serviceGroup -netProfile"
# Ensure there's whitespace before match to prevent substring matches (e.g. server matching MyServer)
foreach ($uniqueObject in $newObjects.InputObject) {
$filteredConfig = $config -match "[^-\S]" + $NSObjectType + " " + $uniqueObject + "[^\S]"
# Look for Pattern Sets
if ($config -match "policy patset") {
$foundObjects = getNSObjects $filteredConfig "policy patset"
if ($foundObjects) {
$nsObjects."policy patset" += $foundObjects
$nsObjects."policy patset" = @($nsObjects."policy patset" | Select-Object -Unique)
}
}
# Look for Data Sets
if ($config -match "policy dataset") {
$foundObjects = getNSObjects $filteredConfig "policy dataset"
if ($foundObjects) {
$nsObjects."policy dataset" += $foundObjects
$nsObjects."policy dataset" = @($nsObjects."policy dataset" | Select-Object -Unique)
}
}
# Look for String Maps
if ($config -match "policy stringmap") {
$foundObjects = getNSObjects $filteredConfig "policy stringmap"
if ($foundObjects) {
$nsObjects."policy stringmap" += $foundObjects
$nsObjects."policy stringmap" = @($nsObjects."policy stringmap" | Select-Object -Unique)
}
}
# Look for URL Sets
if ($config -match "policy urlset") {
$foundObjects = getNSObjects $filteredConfig "policy urlset"
if ($foundObjects) {
$nsObjects."policy urlset" += $foundObjects
$nsObjects."policy urlset" = @($nsObjects."policy urlset" | Select-Object -Unique)
}
}
# Look for Expressions
if ($config -match "policy expression") {
$foundObjects = getNSObjects $filteredConfig "policy expression"
if ($foundObjects) {
$nsObjects."policy expression" += $foundObjects
$nsObjects."policy expression" = @($nsObjects."policy expression" | Select-Object -Unique)
}
}
# Look for Variables
if ($config -match "ns variable") {
$foundObjects = getNSObjects $filteredConfig "ns variable"
if ($foundObjects) {
$nsObjects."ns variable" += $foundObjects
$nsObjects."ns variable" = @($nsObjects."ns variable" | Select-Object -Unique)
}
}
# Look for Policy Maps
if ($config -match "policy map") {
$foundObjects = getNSObjects $filteredConfig "policy map"
if ($foundObjects) {
$nsObjects."policy map" += $foundObjects
$nsObjects."policy map" = @($nsObjects."policy map" | Select-Object -Unique)
}
}
# Look for Limit Identifiers
if ($config -match "ns limitIdentifier") {
$foundObjects = getNSObjects $filteredConfig "ns limitIdentifier"
if ($foundObjects) {
$nsObjects."ns limitIdentifier" += $foundObjects
$nsObjects."ns limitIdentifier" = @($nsObjects."ns limitIdentifier" | Select-Object -Unique)
}
}
# Look for Stream Identifiers
if ($config -match "stream identifier") {
$foundObjects = getNSObjects $filteredConfig "stream identifier"
if ($foundObjects) {
$nsObjects."stream identifier" += $foundObjects
$nsObjects."stream identifier" = @($nsObjects."stream identifier" | Select-Object -Unique)
}
}
# Look for Policy Extensions
if ($config -match "ns extension") {
$foundObjects = getNSObjects $filteredConfig "ns extension"
if ($foundObjects) {
$nsObjects."ns extension" += $foundObjects
$nsObjects."ns extension" = @($nsObjects."ns extension" | Select-Object -Unique)
}
}
# Look for Callouts
if ($filteredConfig -match "CALLOUT") {
if (!$nsObjects."policy httpCallout") { $nsObjects."policy httpCallout" = @()}
$nsObjects."policy httpCallout" += getNSObjects $filteredConfig "policy httpCallout"
$nsObjects."policy httpCallout" = @($nsObjects."policy httpCallout" | Select-Object -Unique)
}
# Look for DNS Records
$foundObjects = getNSObjects $filteredConfig "dns addRec"
if ($foundObjects)
{
$nsObjects."dns addRec" += $foundObjects
$nsObjects."dns addRec" = @($nsObjects."dns addRec" | Select-Object -Unique)
}
$foundObjects = getNSObjects $filteredConfig "dns nsRec"
if ($foundObjects)
{
$nsObjects."dns nsRec" += $foundObjects
$nsObjects."dns nsRec" = @($nsObjects."dns nsRec" | Select-Object -Unique)
}
}
}
function getNSObjects ($matchConfig, $NSObjectType, $paramName, $position) {
# Read all objects of type from from full config
$objectsAll = $config | select-string -Pattern ('^(add|set|bind) ' + $NSObjectType + ' (".*?"|[^-"]\S+)($| )') | % {$_.Matches.Groups[2].value}
# Strip Comments
$matchConfig = $matchConfig | % {$_ -replace '-comment ".*?"' }
# Build Position matching string - match objectCandidate after the # of positions - avoids Action name matching Policy name
if ($position) {
$positionString = ""
1..($position) | % {
$positionString += '(".*?"|[^"]\S+) '
}
$positionString += ".* "
}
# Match objects to matchConfig
# optional searchHint helps prevent too many matches (e.g. "tcp")
$objectMatches = @()
foreach ($objectCandidate in $objectsAll) {
# For regex, replace dots with escaped dots
$objectCandidateDots = $objectCandidate -replace "\.", "\."
# if ($objectCandidate -match "storefront") { write-host $objectCandidate;write-host ($matchConfig);read-host}
# if ($NSObjectType -match "ssl certKey") { write-host $objectCandidate;write-host ($matchConfig);read-host}
# Trying to avoid substring matches
if ($paramName) {
# Compare candidate to term immediately following parameter name
if (($matchConfig -match ($paramName + " " + $objectCandidateDots + "$" )) -or ($matchConfig -match ($paramName + " " + $objectCandidateDots + " "))) {
$objectMatches += $objectCandidate
}
} elseif ($position) {
# Compare candidate to all terms after the specified position # - avoids action name matching policy name
if (($matchConfig -match ($positionString + $objectCandidateDots + "$")) -or ($matchConfig -match ($positionString + $objectCandidateDots + " "))) {
$objectMatches += $objectCandidate
# if ($objectCandidate -match "storefront") { write-host $objectCandidate;write-host ($matchConfig);read-host}
}
} elseif (($matchConfig -match (" " + $objectCandidateDots + "$")) -or ($matchConfig -match (" " + $objectCandidateDots + " "))) {
# Look for candidate at end of string, or with spaces surrounding it - avoids substring matches
$objectMatches += $objectCandidate
} elseif (($matchConfig -match ('"' + $objectCandidateDots + '\\"')) -or ($matchConfig -match ('\(' + $objectCandidateDots + '\)"'))) {
# Look for AppExpert objects (e.g. policy sets, callouts) in policy expressions that don't have spaces around it
$objectMatches += $objectCandidate
} elseif (($matchConfig -match ('//' + $objectCandidateDots)) -or ($matchConfig -match ($objectCandidateDots + ':'))) {
# Look in URLs for DNS records
$objectMatches += $objectCandidate
} elseif (($matchConfig -match ('\.' + $objectCandidateDots + '(\.|"|\(| )'))) {
# Look in Policy Expressions for Policy Extensions - .extension. or .extension" or .extension( or .extension
$objectMatches += $objectCandidate
}
}
return $objectMatches
}
function getHttpVServer ($matchConfig) {
# Matches local LB/CS vServer VIPs in URLs (e.g. StoreFront URL) - No FQDN support
# Read all LB/CS objects of protocol HTTP/SSL from from full config. Extract Name, IP, and Port
if ($matchConfig -match "http://")
{
$objectsAll = $config | select-string -Pattern '^add (lb|cs) vserver (".*?"|[^-"]\S+) HTTP (\d+\.\d+.\d+\.\d+) (\d+) ' | % { New-Object PSObject -property @{
Name = $_.Matches.Groups[2].value
IP = $_.Matches.Groups[3].value
Port = $_.Matches.Groups[4].value
}
}
}
elseif ($matchConfig -match "https://")
{
$objectsAll = $config | select-string -Pattern '^add (lb|cs) vserver (".*?"|[^-"]\S+) SSL (\d+\.\d+.\d+\.\d+) (\d+)' | % { New-Object PSObject -property @{
Name = $_.Matches.Groups[2].value
IP = $_.Matches.Groups[3].value
Port = $_.Matches.Groups[4].value
}
}
}
# Check URL for matching VIP and/or Port number
$objectMatches = @()
foreach ($objectCandidate in $objectsAll)
{
if ($matchConfig -match $objectCandidate.IP)
{
if ($matchConfig -match ":\d+/")
{
if ($matchConfig -match (":" + $objectCandidate.Port + "/"))
{
$objectMatches += $objectCandidate.Name
}
}
elseif ($objectCandidate.Port -eq "80" -or $objectCandidate.Port -eq "443")
{
$objectMatches += $objectCandidate.Name
}
}
}
return $objectMatches
}
function outputObjectConfig ($header, $NSObjectKey, $NSObjectType, $explainText) {
$uniqueObjects = $NSObjects.$NSObjectKey | Select-Object -Unique
# Build header line
$output = "# " + $header + "`n# "
1..$header.length | % {$output += "-"}
$output += "`n"
$matchedConfig = @()
if ($NSObjectType -eq "raw") {
# Print actual Object Values. Don't get output from filtered config.
$matchedConfig = $NSObjects.$NSObjectKey + "`n"
} else {
$firstObject = $true
foreach ($uniqueObject in $uniqueObjects) {
# For regex, replace dots with escaped dots
$uniqueObject = $uniqueObject -replace "\.", "\."
# Don't match "-" to prevent "add serviceGroup -netProfile"
# Ensure there's whitespace before match to prevent substring matches (e.g. MyServer matching server)
if ($NSObjectType) {
# Optional $NSObjectType overrides $NSObjectKey if they don't match (e.g. CA Cert doesn't match certKey)
$matchedConfig += $config -match "[^-\S]" + $NSObjectType + " " + $uniqueObject + "$"
$matchedConfig += $config -match "[^-\S]" + $NSObjectType + " " + $uniqueObject + "[^\S]"
} else {
$matchedConfig += $config -match "[^-\S]" + $NSObjectKey + " " + $uniqueObject + "$"
$matchedConfig += $config -match "[^-\S]" + $NSObjectKey + " " + $uniqueObject + "[^\S]"
}
# if ($uniqueObject -eq "NO_RW_192\.168\.192\.242") {write-host $uniqueObject $matchedConfig}
$matchedConfig += "`n"
}
}
if ($explainText) {
$explainText = @($explainText -split "`n")
$explainText | % {
$matchedConfig += "# *** " + $_
}
$matchedConfig += "`n"
}
# Add line endings to output
$SSLVServerName = ""
foreach ($line in $matchedConfig) {
# if binding new cipher group, remove old ciphers first
# only add unbind line once per SSL object
$SSLvserverNameMatch = $line | select-string -Pattern ('^bind ssl (vserver|service|serviceGroup|monitor) (.*) -cipherName') | % {$_.Matches.Groups[2].value}
if ($SSLvserverNameMatch -and ($SSLVServerName -ne $SSLvserverNameMatch)) {
$SSLVServerName = $SSLvserverNameMatch
$output += ($line -replace "bind (.*) -cipherName .*", "unbind `$1 -cipherName DEFAULT`n")
}
# handle one blank line between mutliple objects of same type
if ($line -ne "`n") {
$output += $line + "`n"
} else {
$output += "`n"
}
}
# Output to file or screen
if ($outputFile -and ($outputFile -ne "screen")) {
$output | out-file $outputFile -Append
} else {
$output
}
}
# Clear configuration from last run
$nsObjects = @{}
$selectionDone =$false
$firstLoop = $true
do {
# Get matching vServer Names. If more than one, prompt for selection.
# This loop allows users to change the vServer filter text
if ($vserver -match " ") {
$vserver = [char]34 + $vserver + [char]34
}
$vservers = $config -match "$vserver" | select-string -Pattern ('^add \w+ vserver (".*?"|[^-"]\S+)') | % {$_.Matches.Groups[1].value}
if (!$vservers) {
# Try substring matches without quotes
if ($vserver -match " ") { $vserver = $vserver -replace [char]34 }
$vservers = $config -match "$vserver" | select-string -Pattern ('^add \w+ vserver (".*?"|[^-"]\S+)') | % {$_.Matches.Groups[1].value}
}
# Make sure it's an array, even if only one match
$vservers = @($vservers)
# FirstLoop flag enables running script without prompting.
# If second loop, then user must have changed the filter, and wants to see results, even if only one (or none).
if (($vservers.length -eq 1 -and $firstLoop) -or $vservers -contains $vserver) {
# Get vServer Type
$vserverType = $config -match " $vservers " | select-string -Pattern ('^add (\w+) vserver') | % {$_.Matches.Groups[1].value}
addNSObject ($vserverType + " vserver") $vservers
$selectionDone = $true
} else {
# Prompt for vServer selection
# Get vServer Type for each vServer name - later display to user
$vserverTypes = @("") * ($vservers.length)
for ($x = 0; $x -lt $vservers.length; $x++) {
$vserverTypes[$x] = $config -match "$vserver" | select-string -Pattern ('^add (\w+) vserver ' + $vservers[$x] + " ") | % {$_.Matches.Groups[1].value}
}
# Change "authentication" to "aaa" so it fits within 4 char column
$vserverTypes = $vserverTypes -replace "authentication", "aaa"
# Get VIPs for each vServer so they can be displayed to the user
$VIPs = @("") * ($vservers.length)
for ($x = 0; $x -lt $vservers.length; $x++) {
$VIPs[$x] = $config -match "$vserver" | select-string -Pattern ('^add \w+ vserver ' + $vservers[$x] + ' \w+ (\d+\.\d+\.\d+\.\d+)') | % {$_.Matches.Groups[1].value}
}
$selected = @("") * ($vservers.length)
do {
$count = 1
cls
$promptString = "Select one or more of the following Virtual Servers for configuration extraction:`n`n"
$promptString += "Virtual Server Filter = $vserver`n`n"
$promptString += " Num Type VIP Name`n"
$maxLength = ($vservers | sort length -desc | select -first 1).length
$promptString += " ----- ---- " + ("-" * 15) + " " + ("-" * $maxLength) + "`n"
write-host $promptString
foreach ($vserverOption in $vservers) {
$promptString = "{0,1} {1,4}: {2,4} {3,15} $vserverOption" -f $selected[$count-1], $count, $vserverTypes[$count-1], $VIPs[$count-1]
if ($selected[$count-1] -eq "*") {
write-host -foregroundcolor yellow $promptString
} else {
write-host $promptString
}
$count++
}
write-host ""
$entry = read-host "Enter Number to select/deselect, * for all, 0 for new filter string, or <Enter> to begin extraction"
if (!$entry -or $entry -eq "") { $selectionDone = $true; break }
if ($entry -eq "*")
{
for ($x = 0; $x -lt $selected.length; $x++) {
if ($selected[$x] -eq "*") {
$selected[$x] = ""
} else
{
$selected[$x] = "*"
}
}
} else
{
try
{
$entry = [int]$entry
if ($entry -lt 0 -or $entry -gt $count)
{
write-host "`nInvalid entry. Press Enter to try again. ";read-host
$entry = "retry"
} elseif ($entry -ge 1 -and $entry -le $count)
{
# Swap select status
if ($selected[$entry -1] -eq "*")
{
$selected[$entry-1] = ""
} else
{
$selected[$entry-1] = "*"
}
} elseif ($entry -eq 0)
{
$newFilter = read-host "Enter new filter string"
$vserver = $newFilter
$entry = ""
$selected = ""
}
} catch
{
write-host "`nInvalid entry. Press Enter to try again. ";read-host
$entry = "retry"
}
}
} while ($entry -and $entry -ne "")
# Run the Get-Output function to ask the user where to save the NetScaler documentation file
if (!$outputFile) { $outputFile = Get-OutputFile $outputfile }
$vserversSelected = @()
for ($x = 0; $x -lt ($selected.length); $x++) {
$vserverTypes = $vserverTypes -replace "aaa", "authentication"
if ($selected[$x] -eq "*") {
addNSObject ($vserverTypes[$x] + " vserver") $vservers[$x]
$vserversSelected += $vservers[$x]
$selectionDone = $true
}
}
$vservers = $vserversSelected
}
$firstLoop = $false
} while (!$selectionDone)
if (!$vservers) { exit }
"`nLooking for objects associated with selected vServers: `n" + ($vservers -join "`n") + "`n"
$Timer = [system.diagnostics.stopwatch]::StartNew()
# Get DNS Servers
addNSObject "dns nameServer" (getNSObjects ($config -match "add dns nameServer") "dns nameServer")
if ($nsObjects."dns nameServer")
{
foreach ($nameserver in $nsObjects."dns nameServer") {
$nameServerConfig = $config -match " $nameserver "
addNSObject "lb vserver" (getNSObjects $nameServerConfig "lb vserver")
}
}
# If $cswBind switch is true, look for CS vServers that the LB, AAA, and/or VPN vServers are bound to.
if ($cswBind){
$cswBindType = @{lb='lbvserver';vpn='vserver';authentication='vserver'}
foreach ($vsrvType in 'lb','vpn','authentication' ) {
if ($nsObjects."$vsrvType vserver") {
foreach ($vsrv in $nsObjects."$vsrvType vserver")
{
# CSW Default virtual server
if ($config -match "bind cs vserver .* -$($cswBindType.$vsrvType) $vsrv"){
addNSObject "cs vserver" ($config -match "bind cs vserver .* -$($cswBindType.$vsrvType) $vsrv" | select-string -Pattern ('^bind cs vserver (".*?"|[^-"]\S+)') | % {$_.Matches.Groups[1].value})
}
# CSW Policy Bind -targetlbserver
if ($config -match "bind cs vserver .* -policyName .* -targetLBVserver $vsrv"){
addNSObject "cs vserver" ($config -match "bind cs vserver .* -policyName .* -targetLBVserver $vsrv" | select-string -Pattern ('^bind cs vserver (".*?"|[^-"]\S+)') | % {$_.Matches.Groups[1].value})
}
# CSW Action -targetlbserver -targetvserver
if ($config -match "add cs action .* -target$($cswBindType.$vsrvType) $vsrv"){
$csaction = ($config -match "add cs action .* -target$($cswBindType.$vsrvType) $vsrv" | select-string -Pattern ('^add cs action (".*?"|[^-"]\S+)') | % {$_.Matches.Groups[1].value})
#CS Policy for CS Action
$cspolicy = ($config -match "add cs policy .* -action $csaction" | select-string -Pattern ('^add cs policy (".*?"|[^-"]\S+)') | % {$_.Matches.Groups[1].value})
#CS vServer for CS Policy
addNSObject "cs vserver" ($config -match "bind cs vserver .* -policyName $cspolicy" | select-string -Pattern ('^bind cs vserver (".*?"|[^-"]\S+)') | % {$_.Matches.Groups[1].value})
}
}
}
}
}
# Look for Backup CSW vServers and Linked LB vServers
if ($nsObjects."cs vserver") {
if ($config -match "enable ns feature.* CS")
{
$NSObjects."cs parameter" = @("enable ns feature CS")
} else {
$NSObjects."cs parameter" = @("# *** CS feature is not enabled")
}
foreach ($csvserver in $nsObjects."cs vserver") {
$vserverConfig = $config -match " $csvserver "
# Backup VServers should be created before Active VServers
$backupVServers = getNSObjects ($vserverConfig) "cs vserver" "-backupVServer"
if ($backupVServers) {
$currentVServers = $nsObjects."cs vserver"
$nsObjects."cs vserver" = @()
addNSObject "cs vserver" ($backupVServers)
$nsObjects."cs vserver" += $currentVServers
}
addNSObject "lb vserver" (getNSObjects $vserverconfig "lb vserver" "-targetLBVserver")2
}
}
# Enumerate CSW vServer config for additional bound objects
if ($nsObjects."cs vserver") {
foreach ($csvserver in $nsObjects."cs vserver") {
$vserverConfig = $config -match "vserver $csvserver "
addNSObject "cs policy" (getNSObjects $vserverConfig "cs policy" "-policyName")
addNSObject "cs policylabel" (getNSObjects $vserverConfig "cs policylabel" "policylabel")
addNSObject "lb vserver" (getNSObjects $vserverConfig "lb vserver" "-lbvserver")
addNSObject "gslb vserver" (getNSObjects $vserverConfig "gslb vserver" "-vserver")
addNSObject "vpn vserver" (getNSObjects $vserverConfig "vpn vserver" "-vserver")
addNSObject "netProfile" (getNSObjects $vserverConfig "netProfile" "-netProfile")
addNSObject "ns trafficDomain" (getNSObjects $vserverConfig "ns trafficDomain" "-td")
addNSObject "ns tcpProfile" (getNSObjects $vserverConfig "ns tcpProfile" "-tcpProfileName")
addNSObject "ns httpProfile" (getNSObjects $vserverConfig "ns httpProfile" "-httpProfileName")
addNSObject "db dbProfile" (getNSObjects $vserverConfig "db dbProfile" "-dbProfileName")
addNSObject "dns profile" (getNSObjects $vserverConfig "dns profile" "-dnsProfileName")
addNSObject "authentication vserver" (getNSObjects $vserverConfig "authentication vserver" "-authnVsName")
addNSObject "authentication authnProfile" (getNSObjects $vserverConfig "authentication authnProfile" "-authnProfile")
addNSObject "authorization policylabel" (getNSObjects $vserverConfig "authorization policylabel")
addNSObject "authorization policy" (getNSObjects $vserverConfig "authorization policy" "-policyName")
addNSObject "audit syslogPolicy" (getNSObjects $vserverConfig "audit syslogPolicy" "-policyName")
addNSObject "audit nslogPolicy" (getNSObjects $vserverConfig "audit nslogPolicy" "-policyName")
addNSObject "ssl policy" (getNSObjects $vserverConfig "ssl policy" "-policyName")
addNSObject "ssl cipher" (getNSObjects $vserverConfig "ssl cipher" "-cipherName")
addNSObject "ssl profile" (getNSObjects $vserverConfig "ssl profile")
addNSObject "ssl certKey" (getNSObjects $vserverConfig "ssl certKey" "-certKeyName")
addNSObject "ssl vserver" (getNSObjects ($config -match "ssl vserver $csvserver ") "ssl vserver")
addNSObject "cmp policy" (getNSObjects $vserverConfig "cmp policy" "-policyName")
addNSObject "cmp policylabel" (getNSObjects $vserverConfig "cmp policylabel" "policylabel")
addNSObject "responder policy" (getNSObjects $vserverConfig "responder policy" "-policyName")
addNSObject "responder policylabel" (getNSObjects $vserverConfig "responder policylabel" "policylabel")
addNSObject "rewrite policy" (getNSObjects $vserverConfig "rewrite policy" "-policyName")
addNSObject "rewrite policylabel" (getNSObjects $vserverConfig "rewrite policylabel" "policylabel")
addNSObject "appflow policy" (getNSObjects $vserverConfig "appflow policy" "-policyName")
addNSObject "appflow policylabel" (getNSObjects $vserverConfig "appflow policylabel" "policylabel")
addNSObject "appfw policy" (getNSObjects $vserverConfig "appfw policy" "-policyName")
addNSObject "appfw policylabel" (getNSObjects $vserverConfig "appfw policylabel" "policylabel")
addNSObject "cache policy" (getNSObjects $vserverConfig "cache policy" "-policyName")
addNSObject "cache policylabel" (getNSObjects $vserverConfig "cache policylabel" "policylabel")
addNSObject "transform policy" (getNSObjects $vserverConfig "transform policy" "-policyName")
addNSObject "transform policylabel" (getNSObjects $vserverConfig "transform policylabel")
addNSObject "tm trafficPolicy" (getNSObjects $vserverConfig "tm trafficPolicy" "-policyName")
addNSObject "feo policy" (getNSObjects $vserverConfig "feo policy" "-policyName")
addNSObject "spillover policy" (getNSObjects $vserverConfig "spillover policy" "-policyName")
addNSObject "appqoe policy" (getNSObjects $vserverConfig "appqoe policy" "-policyName")
addNSObject "ipset" (getNSObjects $vserverConfig "ipset" "-ipset")
addNSObject "analytics profile" (getNSObjects $vserverConfig "analytics profile" "-analyticsProfile")
}
}
# Get CSW Policies from CSW Policy Labels
if ($NSObjects."cs policylabel") {
foreach ($policy in $NSObjects."cs policylabel") {
addNSObject "cs policy" (getNSObjects ($config -match " $policy ") "cs policy")
}
}
# Get CSW Actions from CSW Policies
if ($NSObjects."cs policy") {
foreach ($policy in $NSObjects."cs policy") {
addNSObject "cs action" (getNSObjects ($config -match " $policy ") "cs action")
addNSObject "audit messageaction" (getNSObjects ($config -match "cr policy $policy") "audit messageaction" "-logAction")
}
# Get vServers linked to CSW Actions
if ($NSObjects."cs action") {
foreach ($action in $NSObjects."cs action") {
addNSObject "lb vserver" (getNSObjects ($config -match " $action ") "lb vserver" "-targetLBVserver")
addNSObject "vpn vserver" (getNSObjects ($config -match " $action ") "vpn vserver" "-targetVserver")
addNSObject "authentication vserver" (getNSObjects ($config -match " $action ") "authentication vserver" "-targetVserver")
addNSObject "gslb vserver" (getNSObjects ($config -match " $action ") "gslb vserver" "-targetVserver")
}
}
}
# Look for Backup CR vServers
if ($nsObjects."cr vserver") {
foreach ($crvserver in $nsObjects."cr vserver") {
$vserverConfig = $config -match " $crvserver "
# Backup VServers should be created before Active VServers
$backupVServers = getNSObjects ($vserverConfig) "cr vserver" "-backupVServer"
if ($backupVServers) {
$currentVServers = $nsObjects."cr vserver"
$nsObjects."cr vserver" = @()
addNSObject "cr vserver" ($backupVServers)
$nsObjects."cr vserver" += $currentVServers
}
}
}
# Enumerate CR vServer config for additional bound objects
if ($nsObjects."cr vserver") {
foreach ($crvserver in $nsObjects."cr vserver") {
$vserverConfig = $config -match " $crvserver "
addNSObject "cs policy" (getNSObjects $vserverConfig "cs policy")
addNSObject "cs policylabel" (getNSObjects $vserverConfig "cs policylabel" "policylabel")
addNSObject "cr policy" (getNSObjects $vserverConfig "cr policy")
addNSObject "lb vserver" (getNSObjects $vserverConfig "lb vserver" "-lbvserver")
addNSObject "lb vserver" (getNSObjects $vserverConfig "lb vserver" "-dnsVserverName")
addNSObject "netProfile" (getNSObjects $vserverConfig "netProfile" "-netProfile")
addNSObject "ns trafficDomain" (getNSObjects $vserverConfig "ns trafficDomain" "-td")
addNSObject "ns tcpProfile" (getNSObjects $vserverConfig "ns tcpProfile" "-tcpProfileName")
addNSObject "ns httpProfile" (getNSObjects $vserverConfig "ns httpProfile" "-httpProfileName")
addNSObject "ssl policy" (getNSObjects $vserverConfig "ssl policy" "-policyName")
addNSObject "ssl cipher" (getNSObjects $vserverConfig "ssl cipher")
addNSObject "ssl profile" (getNSObjects $vserverConfig "ssl profile")
addNSObject "ssl certKey" (getNSObjects $vserverConfig "ssl certKey" "-certKeyName")
addNSObject "ssl vserver" (getNSObjects ($config -match "ssl vserver $crvserver ") "ssl vserver")
addNSObject "cmp policy" (getNSObjects $vserverConfig "cmp policy" "-policyName")
addNSObject "cmp policylabel" (getNSObjects $vserverConfig "cmp policylabel" "policylabel")
addNSObject "responder policy" (getNSObjects $vserverConfig "responder policy" "-policyName")
addNSObject "responder policylabel" (getNSObjects $vserverConfig "responder policylabel" "policylabel")
addNSObject "rewrite policy" (getNSObjects $vserverConfig "rewrite policy" "-policyName")
addNSObject "rewrite policylabel" (getNSObjects $vserverConfig "rewrite policylabel" "policylabel")
addNSObject "appflow policy" (getNSObjects $vserverConfig "appflow policy" "-policyName")
addNSObject "appflow policylabel" (getNSObjects $vserverConfig "appflow policylabel" "policylabel")
addNSObject "appfw policy" (getNSObjects $vserverConfig "appfw policy" "-policyName")
addNSObject "appfw policylabel" (getNSObjects $vserverConfig "appfw policylabel" "policylabel")
addNSObject "cache policy" (getNSObjects $vserverConfig "cache policy" "-policyName")
addNSObject "cache policylabel" (getNSObjects $vserverConfig "cache policylabel" "policylabel")
addNSObject "feo policy" (getNSObjects $vserverConfig "feo policy" "-policyName")
addNSObject "spillover policy" (getNSObjects $vserverConfig "spillover policy" "-policyName")
addNSObject "appqoe policy" (getNSObjects $vserverConfig "appqoe policy" "-policyName")
addNSObject "ica policy" (getNSObjects $vserverConfig "ica policy" "-policyName")
addNSObject "ipset" (getNSObjects $vserverConfig "ipset" "-ipset")
addNSObject "analytics profile" (getNSObjects $vserverConfig "analytics profile" "-analyticsProfile")
}
}
# Get Message Actions from CR Policies
if ($NSObjects."cr policy") {
foreach ($policy in $NSObjects."cr policy") {
addNSObject "audit messageaction" (getNSObjects ($config -match "cr policy $policy") "audit messageaction" "-logAction")
}
}
# Get CSW Policies from CSW Policy Labels
if ($NSObjects."cs policylabel") {
foreach ($policy in $NSObjects."cs policylabel") {
addNSObject "cs policy" (getNSObjects ($config -match " $policy ") "cs policy")
}
}
# Get CSW Actions from CSW Policies
if ($NSObjects."cs policy") {
foreach ($policy in $NSObjects."cs policy") {
addNSObject "cs action" (getNSObjects ($config -match " $policy ") "cs action")
addNSObject "audit messageaction" (getNSObjects ($config -match "cr policy $policy") "audit messageaction" "-logAction")
}
# Get vServers linked to CSW Actions
if ($NSObjects."cs action") {
foreach ($action in $NSObjects."cs action") {
addNSObject "lb vserver" (getNSObjects ($config -match " $action ") "lb vserver" "-targetLBVserver")
addNSObject "vpn vserver" (getNSObjects ($config -match " $action ") "vpn vserver" "-targetVserver")
addNSObject "gslb vserver" (getNSObjects ($config -match " $action ") "gslb vserver" "-targetVserver")
}
}
}
# Look for Backup GSLB vServers
if ($nsObjects."gslb vserver") {
foreach ($gslbvserver in $nsObjects."gslb vserver") {
$vserverConfig = $config -match " $gslbvserver "
# Backup VServers should be created before Active VServers
$backupVServers = getNSObjects ($vserverConfig) "gslb vserver" "-backupVServer"
if ($backupVServers) {
$currentVServers = $nsObjects."gslb vserver"
$nsObjects."gslb vserver" = @()
addNSObject "gslb vserver" ($backupVServers)
$nsObjects."gslb vserver" += $currentVServers
}
}
}
# Enumerate GSLB vServer config for additional bound objects
if ($nsObjects."gslb vserver") {
if ($config -match "enable ns feature.* GSLB") {
$NSObjects."gslb parameter" = @("enable ns feature gslb")
} else {
$NSObjects."gslb parameter" = @("# *** GSLB feature is not enabled")
}
foreach ($gslbvserver in $nsObjects."gslb vserver") {
$vserverConfig = $config -match " $gslbvserver "
addNSObject "gslb service" (getNSObjects $vserverConfig "gslb service" "-serviceName")
addNSObject "ssl vserver" (getNSObjects ($config -match "ssl vserver $gslbvserver ") "ssl vserver")
addNSObject "dns soaRec" (getNSObjects $vserverConfig "dns soaRec")
addNSObject "dns nsRec" (getNSObjects $vserverConfig "dns nsRec")
}
if ($NSObjects."gslb service")
{
foreach ($service in $NSObjects."gslb service")
{
# wrap config matches in spaces to avoid substring matches
$serviceConfig = $config -match " $service "
addNSObject "monitor" (getNSObjects $serviceConfig "lb monitor" "-monitorName")
addNSObject "server" (getNSObjects $serviceConfig "server")
addNSObject "ssl profile" (getNSObjects $serviceConfig "ssl profile")
addNSObject "netProfile" (getNSObjects $serviceConfig "netProfile" "-netProfile")
addNSObject "ns trafficDomain" (getNSObjects $serviceConfig "ns trafficDomain" "-td")
addNSObject "dns view" (getNSObjects $serviceConfig "dns view" "-viewName")
addNSObject "gslb site" (getNSObjects $serviceConfig "gslb site" "-siteName")
}
}
if ($NSObjects."gslb site")
{
foreach ($site in $NSObjects."gslb site")
{
$siteConfig = $config -match "add gslb site $site "
addNSObject "ns rpcNode" (getNSObjects $siteConfig "ns rpcNode")
}
}
addNSObject "dns cnameRec" (getNSObjects ($config -match "^add dns cnameRec ") "dns cnameRec")
addNSObject "dns addRec" (getNSObjects ($config | select-string -Pattern "^add dns addRec" | select-string -NotMatch -Pattern ".root-servers.net") "dns addRec")
addNSObject "gslb location" ($config -match "^set locationParameter") "gslb location"
addNSObject "gslb location" ($config -match " locationFile ") "gslb location"
addNSObject "gslb location" ($config -match "^add location ") "gslb location"
addNSObject "gslb parameter" ($config -match "^set gslb parameter ") "gslb parameter"
addNSObject "gslb parameter" ($config -match "^set dns parameter") "gslb parameter"
# Get all global DNS Responder policies in case they affect GSLB DNS traffic
addNSObject "responder policy" (getNSObjects ($config -match "^bind responder global .*? -type DNS_REQ_") "responder policy")
# Get all global DNS Policy bindings in case they affect ADNS traffic?
addNSObject "dns policy" (getNSObjects ($config -match "^bind dns global") "dns policy")
addNSObject "adns service" ($config -match '^add service (".*?"|[^-"]\S+) \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} ADNS') "adns service"
# Get all DNS LB vServers in case they are used for DNS Queries?
addNSObject "lb vserver" (getNSObjects ($config -match '^add lb vserver (".*?"|[^-"]\S+) DNS') "lb vserver")
}
# Get DNS Actions and DNS Polices from DNS Views
if ($nsObjects."dns view") {
foreach ($view in $nsObjects."dns view") {
addNSObject "dns action" (getNSObjects ($config -match "dns action .*? -viewName $view") "dns action")
}
foreach ($action in $nsObjects."dns action") {
addNSObject "dns policy" (getNSObjects ($config -match "dns policy .*? $action") "dns policy" )
}
}
if ($nsObjects."dns policy") {
# Get DNS Actions for global DNS policies discovered earlier
foreach ($policy in $nsObjects."dns policy") {
addNSObject "dns action" (getNSObjects ($config -match "dns policy $policy") "dns action")
addNSObject "audit messageaction" (getNSObjects ($config -match "dns policy $policy") "audit messageaction" "-logAction")
}
# Get DNS Profiles linked to DNS Actions
foreach ($action in $nsObjects."dns action") {
addNSObject "dns profile" (getNSObjects ($config -match "dns action $action") "dns profile" "-dnsProfileName" )
}
# Get DNS Views linked to DNS Actions
foreach ($action in $nsObjects."dns action") {
addNSObject "dns view" (getNSObjects ($config -match "dns action $action") "dns view" "-viewName" )
}
addNSObject "dns global" ($config -match "bind dns global ") "dns global"
}
# Enumerate VPN vServer config for additional bound objects
if ($nsObjects."vpn vserver") {
if ($config -match "enable ns feature.* SSLVPN") {
$NSObjects."vpn parameter" = @("enable ns feature SSLVPN")
} else {
$NSObjects."vpn parameter" = @("# *** NetScaler Gateway feature is not enabled")
}
addNSObject "vpn parameter" ($config -match "vpn parameter") "vpn parameter"
addNSObject "vpn parameter" ($config -match "ica parameter") "vpn parameter"
addNSObject "vpn parameter" ($config -match "aaa parameter") "vpn parameter"
addNSObject "vpn parameter" ($config -match "dns suffix") "vpn parameter"
foreach ($vpnvserver in $nsObjects."vpn vserver") {
$vserverConfig = $config -match " $vpnvserver "
addNSObject "cs policylabel" (getNSObjects $vserverConfig "cs policylabel")
addNSObject "cs policy" (getNSObjects $vserverConfig "cs policy")
addNSObject "ns tcpProfile" (getNSObjects $vserverConfig "ns tcpProfile")
addNSObject "netProfile" (getNSObjects $vserverConfig "netProfile" "-netProfile")
addNSObject "ns httpProfile" (getNSObjects $vserverConfig "ns httpProfile" "-httpProfileName")
addNSObject "ns trafficDomain" (getNSObjects $vserverConfig "ns trafficDomain" "-td")
addNSObject "authentication authnProfile" (getNSObjects $vserverConfig "authentication authnProfile" "-authnProfile")
addNSObject "vpn pcoipVserverProfile" (getNSObjects $vserverConfig "vpn pcoipVserverProfile" "-pcoipVserverProfileName")
addNSObject "vpn intranetApplication" (getNSObjects $vserverConfig "vpn intranetApplication" "-intranetApplication")
addNSObject "vpn portaltheme" (getNSObjects $vserverConfig "vpn portaltheme" "-portaltheme")
addNSObject "vpn eula" (getNSObjects $vserverConfig "vpn eula" "-eula")
addNSObject "vpn nextHopServer" (getNSObjects $vserverConfig "vpn nextHopServer" "-nextHopServer")
addNSObject "authentication ldapPolicy" (getNSObjects $vserverConfig "authentication ldapPolicy" "-policy")
addNSObject "authentication radiusPolicy" (getNSObjects $vserverConfig "authentication radiusPolicy" "-policy")
addNSObject "authentication samlIdPPolicy" (getNSObjects $vserverConfig "authentication samlIdPPolicy")
addNSObject "authentication samlPolicy" (getNSObjects $vserverConfig "authentication samlPolicy")
addNSObject "authentication certPolicy" (getNSObjects $vserverConfig "authentication certPolicy")
addNSObject "authentication dfaPolicy" (getNSObjects $vserverConfig "authentication dfaPolicy")
addNSObject "authentication localPolicy" (getNSObjects $vserverConfig "authentication localPolicy")
addNSObject "authentication negotiatePolicy" (getNSObjects $vserverConfig "authentication negotiatePolicy")
addNSObject "authentication tacacsPolicy" (getNSObjects $vserverConfig "authentication tacacsPolicy")
addNSObject "authentication webAuthPolicy" (getNSObjects $vserverConfig "authentication webAuthPolicy")
addNSObject "aaa preauthenticationpolicy" (getNSObjects $vserverConfig "aaa preauthenticationpolicy" "-policy")
addNSObject "vpn sessionPolicy" (getNSObjects $vserverConfig "vpn sessionPolicy" "-policy")
addNSObject "vpn trafficPolicy" (getNSObjects $vserverConfig "vpn trafficPolicy" "-policy")
addNSObject "vpn clientlessAccessPolicy" (getNSObjects $vserverConfig "vpn clientlessAccessPolicy" "-policy")
addNSObject "authorization policylabel" (getNSObjects $vserverConfig "authorization policylabel")
addNSObject "authorization policy" (getNSObjects $vserverConfig "authorization policy" "-policy")
addNSObject "responder policy" (getNSObjects $vserverConfig "responder policy" "-policy")
addNSObject "responder policylabel" (getNSObjects $vserverConfig "responder policylabel" "policylabel")
addNSObject "rewrite policy" (getNSObjects $vserverConfig "rewrite policy" "-policy")
addNSObject "rewrite policylabel" (getNSObjects $vserverConfig "rewrite policylabel" "policylabel")
addNSObject "appflow policy" (getNSObjects $vserverConfig "appflow policy" "-policy")
addNSObject "appflow policylabel" (getNSObjects $vserverConfig "appflow policylabel" "policylabel")
addNSObject "cache policy" (getNSObjects $vserverConfig "cache policy" "-policy")
addNSObject "cache policylabel" (getNSObjects $vserverConfig "cache policylabel" "policylabel")
addNSObject "audit syslogPolicy" (getNSObjects $vserverConfig "audit syslogPolicy" "-policy")
addNSObject "audit nslogPolicy" (getNSObjects $vserverConfig "audit nslogPolicy" "-policy")
addNSObject "ica policy" (getNSObjects $vserverConfig "ica policy" "-policy")
addNSObject "ssl policy" (getNSObjects $vserverConfig "ssl policy" "-policy")
addNSObject "ssl cipher" (getNSObjects $vserverConfig "ssl cipher")
addNSObject "ssl profile" (getNSObjects $vserverConfig "ssl profile")
addNSObject "ssl certKey" (getNSObjects $vserverConfig "ssl certKey" "-certkeyName")
addNSObject "ssl vserver" (getNSObjects ($config -match "ssl vserver $vpnvserver ") "ssl vserver")
addNSObject "vpn url" (getNSObjects $vserverConfig "vpn url" "-urlName")
addNSObject "ipset" (getNSObjects $vserverConfig "ipset" "-ipset")
addNSObject "analytics profile" (getNSObjects $vserverConfig "analytics profile" "-analyticsProfile")
}
addNSObject "aaa group" (getNSObjects ($config -match "add aaa group") "aaa group")
addNSObject "vpn global" ($config -match "bind vpn global ") "vpn global"
}
# Get CSW Policies from CSW Policy Labels
if ($NSObjects."cs policylabel") {
foreach ($policy in $NSObjects."cs policylabel") {
addNSObject "cs policy" (getNSObjects ($config -match " $policy ") "cs policy")
}
}
# Get CSW Actions from CSW Policies
if ($NSObjects."cs policy") {
foreach ($policy in $NSObjects."cs policy") {
addNSObject "cs action" (getNSObjects ($config -match " $policy ") "cs action")
addNSObject "audit messageaction" (getNSObjects ($config -match "cr policy $policy") "audit messageaction" "-logAction")
}
# Get vServers linked to CSW Actions
if ($NSObjects."cs action") {
foreach ($action in $NSObjects."cs action") {
addNSObject "lb vserver" (getNSObjects ($config -match " $action ") "lb vserver" "-targetLBVserver")
addNSObject "vpn vserver" (getNSObjects ($config -match " $action ") "vpn vserver" "-targetVserver")
addNSObject "gslb vserver" (getNSObjects ($config -match " $action ") "gslb vserver" "-targetVserver")
}
}
}
# Get objects bound to VPN Global
if ($nsObjects."vpn global") {
$vserverConfig = $config -match "bind vpn global "
addNSObject "vpn intranetApplication" (getNSObjects $vserverConfig "vpn intranetApplication" "-intranetApplication")
addNSObject "vpn portaltheme" (getNSObjects $vserverConfig "vpn portaltheme" "-portaltheme")
addNSObject "vpn eula" (getNSObjects $vserverConfig "vpn eula" "-eula")
addNSObject "vpn nextHopServer" (getNSObjects $vserverConfig "vpn nextHopServer" "-nextHopServer")
addNSObject "authentication ldapPolicy" (getNSObjects $vserverConfig "authentication ldapPolicy" "-policyName")
addNSObject "authentication radiusPolicy" (getNSObjects $vserverConfig "authentication radiusPolicy" "-policyName")
addNSObject "authentication samlIdPPolicy" (getNSObjects $vserverConfig "authentication samlIdPPolicy")
addNSObject "authentication samlPolicy" (getNSObjects $vserverConfig "authentication samlPolicy")
addNSObject "authentication certPolicy" (getNSObjects $vserverConfig "authentication certPolicy")
addNSObject "authentication dfaPolicy" (getNSObjects $vserverConfig "authentication dfaPolicy")
addNSObject "authentication localPolicy" (getNSObjects $vserverConfig "authentication localPolicy")
addNSObject "authentication negotiatePolicy" (getNSObjects $vserverConfig "authentication negotiatePolicy")
addNSObject "authentication tacacsPolicy" (getNSObjects $vserverConfig "authentication tacacsPolicy")
addNSObject "authentication webAuthPolicy" (getNSObjects $vserverConfig "authentication webAuthPolicy")
addNSObject "vpn sessionPolicy" (getNSObjects $vserverConfig "vpn sessionPolicy" "-policyName")
addNSObject "vpn trafficPolicy" (getNSObjects $vserverConfig "vpn trafficPolicy" "-policyName")