-
Notifications
You must be signed in to change notification settings - Fork 59
/
ArcGISConfigure.ps1
2061 lines (1929 loc) · 125 KB
/
ArcGISConfigure.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
Configuration ArcGISConfigure
{
Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DscResource -ModuleName ArcGIS
Import-DscResource -Name MSFT_xFirewall
Import-DscResource -Name ArcGIS_FileShare
Import-DscResource -Name ArcGIS_Server
Import-DscResource -Name ArcGIS_WindowsService
Import-DscResource -Name ArcGIS_Service_Account
Import-DscResource -Name ArcGIS_Portal
Import-DscResource -Name ArcGIS_DataStore
Import-DscResource -Name ArcGIS_IIS_TLS
Import-DscResource -Name ArcGIS_WebAdaptor
Import-DscResource -Name ArcGIS_Federation
Import-DscResource -Name ArcGIS_TLSCertificateImport
Import-DscResource -Name ArcGIS_LB
Import-DscResource -Name ArcGIS_GeoEvent
Import-DSCResource -Name ArcGIS_EGDB
Import-DSCResource -Name ArcGIS_WaitForComponent
Import-DSCResource -Name ArcGIS_WaitForFileShare
Import-DSCResource -Name ArcGIS_WaitForSQLServer
Import-DSCResource -Name ArcGIS_DataStoreItem
Import-DSCResource -Name ArcGIS_Server_TLS
Import-DSCResource -Name ArcGIS_Portal_TLS
$PrimaryServerMachine = ""
$PrimaryPortalMachine = ""
$PrimaryDataStore = ""
$PrimaryBigDataStore = ""
$PrimaryTileCache = ""
for ( $i = 0; $i -lt $AllNodes.count; $i++ )
{
$Role = $AllNodes[$i].Role
if($Role -icontains 'Server' -and -not($PrimaryServerMachine))
{
$PrimaryServerMachine = $AllNodes[$i].NodeName
}
if($Role -icontains 'Portal' -and -not($PrimaryPortalMachine))
{
$PrimaryPortalMachine= $AllNodes[$i].NodeName
}
if($Role -icontains 'DataStore')
{
$DsTypes = $AllNodes[$i].DataStoreTypes
if($DsTypes -icontains "Relational" -and -not($PrimaryDataStore))
{
$PrimaryDataStore = $AllNodes[$i].NodeName
}
if($DsTypes -icontains "SpatioTemporal" -and -not($PrimaryBigDataStore))
{
$PrimaryBigDataStore = $AllNodes[$i].NodeName
}
if($DsTypes -icontains "TileCache" -and -not($PrimaryTileCache))
{
$PrimaryTileCache = $AllNodes[$i].NodeName
}
}
}
Node $AllNodes.NodeName
{
$FileShareMachine = ($AllNodes | Where-Object { $_.Role -icontains 'FileShare' }).NodeName
$MachineFQDN = Get-FQDN $Node.NodeName
$SAPassword = ConvertTo-SecureString $ConfigurationData.ConfigData.Credentials.ServiceAccount.Password -AsPlainText -Force
$SACredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ($ConfigurationData.ConfigData.Credentials.ServiceAccount.UserName, $SAPassword )
$PSAPassword = ConvertTo-SecureString $ConfigurationData.ConfigData.Credentials.PrimarySiteAdmin.Password -AsPlainText -Force
$PSACredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ($ConfigurationData.ConfigData.Credentials.PrimarySiteAdmin.UserName, $PSAPassword )
$Federation = if($ConfigurationData.ConfigData.Federation){$true}else{$false}
if(-not($Federation))
{
$ServerCheck = (($AllNodes | Where-Object { $_.Role -icontains 'Server' } | Measure-Object).Count -gt 0)
$DataStoreCheck = (($AllNodes | Where-Object { $_.Role -icontains 'DataStore' } | Measure-Object).Count -gt 0)
$PortalCheck = (($AllNodes | Where-Object { $_.Role -icontains 'Portal' } | Measure-Object).Count -gt 0)
if($ServerCheck -and $PortalCheck)
{
$Federation = $True
if($DataStoreCheck)
{
$HostingServer = $True
}
}
}
if(-Not($ConfigurationData.ConfigData.Credentials.ServiceAccount.IsDomainAccount)){
User ArcGIS_RunAsAccount
{
UserName = $ConfigurationData.ConfigData.Credentials.ServiceAccount.UserName
Password = $SACredential
FullName = 'ArcGIS Run As Account'
Ensure = "Present"
PasswordChangeRequired = $false
PasswordNeverExpires = $true
}
}
if($ConfigurationData.ConfigData.DebugMode)
{
Group-Object RemoteDesktopUsers
{
GroupName = 'Remote Desktop Users'
Ensure = 'Present'
MembersToInclude = $ConfigurationData.ConfigData.Credentials.ServiceAccount.UserName
DependsOn = if(-not($ConfigurationData.ConfigData.Credentials.ServiceAccount.IsDomainAccount)){@('[User]ArcGIS_RunAsAccount')}else{@()}
}
}
#Removes the Requirement for the Ordering inside roles.
$NodeRoleArray = @()
if($Node.Role -icontains "FileShare")
{
$NodeRoleArray += "FileShare"
}
if($Node.Role -icontains "RasterDataStoreItem")
{
$NodeRoleArray += "RasterDataStoreItem"
}
if($Node.Role -icontains "Server")
{
$NodeRoleArray += "Server"
}
if($Node.Role -icontains "Portal")
{
$NodeRoleArray += "Portal"
}
if($Node.Role -icontains "DataStore")
{
$NodeRoleArray += "DataStore"
}
if($Node.Role -icontains "ServerWebAdaptor")
{
$NodeRoleArray += "ServerWebAdaptor"
}
if($Node.Role -icontains "PortalWebAdaptor")
{
$NodeRoleArray += "PortalWebAdaptor"
}
if($Node.Role -icontains "LoadBalancer")
{
$NodeRoleArray += "LoadBalancer"
}
for ( $i = 0; $i -lt $NodeRoleArray.Count; $i++ )
{
$NodeRole = $NodeRoleArray[$i]
Switch($NodeRole)
{
'Server'{
$Depends = @()
$IsWebGIS = (($AllNodes | Where-Object { $_.Role -icontains 'Portal' } | Measure-Object).Count -gt 0)
$IsMultiMachineServer = (($AllNodes | Where-Object { $_.Role -icontains 'Server' } | Measure-Object).Count -gt 1)
$HasDataStoreNodes = (($AllNodes | Where-Object { $_.Role -icontains 'DataStore' } | Measure-Object).Count -gt 0)
$OpenFirewallPorts = (-not($IsWebGIS) -or ($ConfigData.ServerEndPoint -as [ipaddress]) -or $HasDataStoreNodes -or $IsMultiMachineServer)
if($OpenFirewallPorts) # Server only deployment or behind an ILB or has DataStore nodes that need to register using admin
{
$Depends += '[xFirewall]Server_FirewallRules'
xFirewall Server_FirewallRules
{
Name = "ArcGISServer"
DisplayName = "ArcGIS for Server"
DisplayGroup = "ArcGIS for Server"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("6080","6443")
Protocol = "TCP"
}
}
if($IsMultiMachineServer)
{
$Depends += '[xFirewall]Server_FirewallRules_Internal'
xFirewall Server_FirewallRules_Internal
{
Name = "ArcGISServerInternal"
DisplayName = "ArcGIS for Server Internal RMI"
DisplayGroup = "ArcGIS for Server"
Ensure = "Present"
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("4000-4004")
Protocol = "TCP"
}
if($ConfigurationData.ConfigData.ServerRole -ieq 'GeoAnalytics')
{
$Depends += '[xFirewall]GeoAnalytics_InboundFirewallRules'
$Depends += '[xFirewall]GeoAnalytics_OutboundFirewallRules'
xFirewall GeoAnalytics_InboundFirewallRules
{
Name = "ArcGISGeoAnalyticsInboundFirewallRules"
DisplayName = "ArcGIS GeoAnalytics"
DisplayGroup = "ArcGIS GeoAnalytics"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("2181","2182","2190","7077") # Spark and Zookeeper
Protocol = "TCP"
}
xFirewall GeoAnalytics_OutboundFirewallRules
{
Name = "ArcGISGeoAnalyticsOutboundFirewallRules"
DisplayName = "ArcGIS GeoAnalytics"
DisplayGroup = "ArcGIS GeoAnalytics"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("2181","2182","2190","7077") # Spark and Zookeeper
Protocol = "TCP"
Direction = "Outbound"
}
xFirewall GeoAnalyticsCompute_InboundFirewallRules
{
Name = "ArcGISGeoAnalyticsComputeInboundFirewallRules"
DisplayName = "ArcGIS GeoAnalytics"
DisplayGroup = "ArcGIS GeoAnalytics"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("56540-56550") # GA Compute
Protocol = "TCP"
}
xFirewall GeoAnalyticsCompute_OutboundFirewallRules
{
Name = "ArcGISGeoAnalyticsComputeOutboundFirewallRules"
DisplayName = "ArcGIS GeoAnalytics"
DisplayGroup = "ArcGIS GeoAnalytics"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("56540-56550") # GA Compute
Protocol = "TCP"
Direction = "Outbound"
}
}
}
ArcGIS_WindowsService ArcGIS_for_Server_Service
{
Name = 'ArcGIS Server'
Credential = $SACredential
StartupType = 'Automatic'
State = 'Running'
DependsOn = $Depends
}
$Depends += '[ArcGIS_WindowsService]ArcGIS_for_Server_Service'
$ConfigStoreLocation = $ConfigurationData.ConfigData.Server.ConfigStoreLocation
$ServerDirectoriesRootLocation = $ConfigurationData.ConfigData.Server.ServerDirectoriesRootLocation
if($FileShareMachine)
{
#$ConfigStoreLocation = "\\$($FileShareMachine)\$($ConfigurationData.ConfigData.FileShareName)\$($ConfigurationData.ConfigData.Server.ConfigStoreLocation)"
#$ServerDirectoriesRootLocation = "\\$($FileShareMachine)\$($ConfigurationData.ConfigData.FileShareName)\$($ConfigurationData.ConfigData.Server.ServerDirectoriesRootLocation)"
$FilePathsForServer = @()
$FilePathsForServer += $ConfigStoreLocation
$FilePathsForServer += $ServerDirectoriesRootLocation
if($ConfigurationData.ConfigData.Credentials.ServiceAccount.IsDomainAccount){
$FileShareCredential = $SACredential
}else{
$FileShareCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ("$FileShareMachine\$($ConfigurationData.ConfigData.Credentials.ServiceAccount.UserName)", $SAPassword )
}
if($Node.WMFVersion -gt 4){
WaitForAll "WaitForAllFileShareServer$($Node.NodeName)"{
ResourceName = "[ArcGIS_FileShare]FileShare"
NodeName = $FileShareMachine
RetryIntervalSec = 20
RetryCount = 30
DependsOn = $Depends
}
$Depends += "[WaitForAll]WaitForAllFileShareServer$($Node.NodeName)"
}else{
ArcGIS_WaitForFileShare "WaitForFileShareServer$($Node.NodeName)"
{
FilePaths = ($FilePathsForServer -join ',')
Ensure = "Present"
RetryIntervalSec = 20
RetryCount = 30
Credential = $FileShareCredential
DependsOn = $Depends
}
$Depends += "[ArcGIS_WaitForFileShare]WaitForFileShareServer$($Node.NodeName)"
}
}
<#else
{
File ConfigStoreRootLocation
{
Type = 'Directory'
DestinationPath = $ConfigStoreLocation
Ensure = 'Present'
Force = $true
}
}#>
ArcGIS_Service_Account Server_RunAs_Account
{
Name = 'ArcGIS Server'
RunAsAccount = $SACredential
Ensure = 'Present'
DependsOn = $Depends
}
$Depends += '[ArcGIS_Service_Account]Server_RunAs_Account'
if($Node.NodeName -ine $PrimaryServerMachine)
{
if($Node.WMFVersion -gt 4){
WaitForAll "WaitForAllServer$($PrimaryServerMachine)"{
ResourceName = "[ArcGIS_Server]Server$($PrimaryServerMachine)"
NodeName = $PrimaryServerMachine
RetryIntervalSec = 60
RetryCount = 100
DependsOn = $Depends
}
$Depends += "[WaitForAll]WaitForAllServer$($PrimaryServerMachine)"
}else{
ArcGIS_WaitForComponent "WaitForServer$($PrimaryServerMachine)"
{
Component = "Server"
InvokingComponent = "Server"
ComponentHostName = (Get-FQDN $PrimaryServerMachine)
ComponentContext = "arcgis"
Ensure = "Present"
Credential = $PSACredential
RetryIntervalSec = 60
RetryCount = 100
}
$Depends += "[ArcGIS_WaitForComponent]WaitForServer$($PrimaryServerMachine)"
}
}
ArcGIS_Server "Server$($Node.NodeName)"
{
Ensure = 'Present'
SiteAdministrator = $PSACredential
ConfigurationStoreLocation = $ConfigStoreLocation
ServerDirectoriesRootLocation = $ServerDirectoriesRootLocation
Join = if($Node.NodeName -ine $PrimaryServerMachine) { $true } else { $false }
PeerServerHostName = Get-FQDN $PrimaryServerMachine
DependsOn = $Depends
LogLevel = if($ConfigurationData.ConfigData.DebugMode) { 'DEBUG' } else { 'WARNING' }
SingleClusterMode = if(($AllNodes | Where-Object { $_.Role -icontains 'Server' } | Measure-Object).Count -gt 0) { $true } else { $false }
}
$Depends += "[ArcGIS_Server]Server$($Node.NodeName)"
if($ConfigurationData.ConfigData.GeoEventServer)
{
ArcGIS_Service_Account GeoEvent_RunAs_Account
{
Name = 'ArcGISGeoEvent'
RunAsAccount = $SACredential
Ensure = "Present"
DependsOn = $Depends
DataDir = "$env:ProgramData\Esri\GeoEvent"
}
$Depends += "[ArcGIS_Service_Account]GeoEvent_RunAs_Account"
ArcGIS_WindowsService ArcGIS_GeoEvent_Service
{
Name = 'ArcGISGeoEvent'
Credential = $SACredential
StartupType = 'Automatic'
State = 'Running'
DependsOn = $Depends
}
$Depends += "[ArcGIS_WindowsService]ArcGIS_GeoEvent_Service"
xFirewall GeoEvent_FirewallRules
{
Name = "ArcGISGeoEventFirewallRules"
DisplayName = "ArcGIS GeoEvent"
DisplayGroup = "ArcGIS GeoEvent"
Ensure = "Present"
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("6143","6180","5565","5575")
Protocol = "TCP"
DependsOn = $Depends
}
$Depends += "[xFirewall]GeoEvent_FirewallRules"
ArcGIS_GeoEvent ArcGIS_GeoEvent
{
Name = 'ArcGIS GeoEvent'
Ensure = "Present"
SiteAdministrator = $PSACredential
WebSocketContextUrl = "wss://$($MachineFQDN):6143/geoevent"
DependsOn = $Depends
#SiteAdminUrl = if($ConfigData.ExternalDNSName) { "https://$($ConfigData.ExternalDNSName)/arcgis/admin" } else { $null }
}
$Depends += "[xFirewall]GeoEvent_FirewallRules"
if($IsMultiMachineServer)
{
xFirewall GeoEvent_FirewallRules_MultiMachine
{
Name = "ArcGISGeoEventFirewallRulesCluster"
DisplayName = "ArcGIS GeoEvent Extension Cluster"
DisplayGroup = "ArcGIS GeoEvent Extension"
Ensure = "Present"
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("2181","2182","2190","27271","27272","27273")
Protocol = "TCP"
DependsOn = $Depends
}
$Depends += "[xFirewall]GeoEvent_FirewallRules_MultiMachine"
xFirewall GeoEvent_FirewallRules_MultiMachine_OutBound
{
Name = "ArcGISGeoEventFirewallRulesClusterOutbound"
DisplayName = "ArcGIS GeoEvent Extension Cluster Outbound"
DisplayGroup = "ArcGIS GeoEvent Extension"
Ensure = "Present"
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
RemotePort = ("2181","2182","2190","27271","27272","27273")
Protocol = "TCP"
Direction = "Outbound"
DependsOn = $Depends
}
$Depends += "[xFirewall]GeoEvent_FirewallRules_MultiMachine_OutBound"
xFirewall GeoEventService_Firewall
{
Name = "ArcGISGeoEventGateway"
DisplayName = "ArcGIS GeoEvent Gateway"
DisplayGroup = "ArcGIS GeoEvent Gateway"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("9092")
Protocol = "TCP"
DependsOn = $Depends
}
$Depends += "[xFirewall]GeoEventService_Firewall"
}
if(Get-Service 'ArcGISGeoEventGateway' -ErrorAction Ignore)
{
ArcGIS_WindowsService ArcGIS_GeoEventGateway_Service
{
Name = 'ArcGISGeoEventGateway'
Credential = $SACredential
StartupType = 'Automatic'
State = 'Running'
DependsOn = $Depends
}
$Depends += "[ArcGIS_WindowsService]ArcGIS_GeoEventGateway_Service"
}
}
if(($Node.NodeName -ieq $PrimaryServerMachine) -and $HasSQLServer)
{
ForEach($svr in ($AllNodes | Where-Object { $_.Role -icontains 'SQLServer' }))
{
$DatabaseServerAdministratorPassword = ConvertTo-SecureString $ConfigurationData.ConfigData.SQLServer.DatabaseAdminUser.Password -AsPlainText -Force
$DatabaseServerAdministratorCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ($ConfigurationData.ConfigData.SQLServer.DatabaseAdminUser.UserName, $DatabaseServerAdministratorPassword )
if($Node.WMFVersion -gt 4){
WaitForAll "WaitForAllSQLServer$($svr.NodeName)"{
ResourceName = "[Script]CreateDatabaseAdminUser"
NodeName = $svr.NodeName
RetryIntervalSec = 60
RetryCount = 60
DependsOn = $Depends
}
$Depends += "[WaitForAll]WaitForAllSQLServer$($svr.NodeName)"
}else{
ArcGIS_WaitForSQLServer "WaitForSQLServer$($svr.NodeName)"
{
SQLServerMachineName = (Get-FQDN $svr.NodeName)
Ensure = 'Present'
Credential = $DatabaseServerAdministratorCredential
RetryIntervalSec = 60
RetryCount = 60
}
$Depends += "[WaitForAll]ArcGIS_WaitForSQLServer$($svr.NodeName)"
}
$SDEUserPassword = ConvertTo-SecureString $ConfigurationData.ConfigData.SQLServer.SDEUser.Password -AsPlainText -Force
$SDEUserCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ($ConfigurationData.ConfigData.SQLServer.SDEUser.UserName, $SDEUserPassword )
$DatabaseUserPassword = ConvertTo-SecureString $ConfigurationData.ConfigData.SQLServer.DatabaseUser.Password -AsPlainText -Force
$DatabaseUserCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ($ConfigurationData.ConfigData.SQLServer.DatabaseUser.UserName, $DatabaseUserPassword )
$DatabaseServerHostName = (Get-FQDN $svr.NodeName)
$DatabaseName = $ConfigurationData.ConfigData.SQLServer.DatabaseName
if(($DatabaseOption -ine 'None') -and $DatabaseServerHostName -and $DatabaseName -and $DatabaseServerAdministratorCredential -and $SDEUserCredential -and $DatabaseUserCredential)
{
ArcGIS_EGDB RegisterEGDB
{
DatabaseServer = $DatabaseServerHostName
DatabaseName = $DatabaseName
ServerSiteAdministrator = $PSACredential
DatabaseServerAdministrator = $DatabaseServerAdministratorCredential
SDEUser = $SDEUserCredential
DatabaseUser = $DatabaseUserCredential
IsManaged = $ConfigurationData.ConfigData.SQLServer.IsManaged
EnableGeodatabase = $ConfigurationData.ConfigData.SQLServer.EnableGeodatabase
DatabaseType = 'SQLServerDatabase'
Ensure = 'Present'
DependsOn = $Depends
}
$Depends += "[ArcGIS_EGDB]RegisterEGDB"
}
}
}
if((($AllNodes | Where-Object { ($_.Role -icontains 'LoadBalancer')} | Measure-Object).Count -eq 0))
{
if(($AllNodes | Where-Object { ($_.Role -icontains 'ServerWebAdaptor')} | Measure-Object).Count -eq 0)
{
if($ConfigurationData.ConfigData.Server.SslCertifcate.Path)
{
ArcGIS_Server_TLS "Server_TLS_$($Node.NodeName)"
{
Ensure = 'Present'
SiteName = 'arcgis'
SiteAdministrator = $PSACredential
CName = $ConfigurationData.ConfigData.Server.SslCertifcate.Alias
RegisterWebAdaptorForCName = $False
CertificateFileLocation = $ConfigurationData.ConfigData.Server.SslCertifcate.Path
CertificatePassword = $ConfigurationData.ConfigData.Server.SslCertifcate.Password
EnableSSL = $True
DependsOn = $Depends
}
}
else
{
ArcGIS_Server_TLS "Server_TLS_$($Node.NodeName)"
{
Ensure = 'Present'
SiteName = 'arcgis'
SiteAdministrator = $PSACredential
CName = $MachineFQDN
RegisterWebAdaptorForCName = $False
EnableSSL = $True
DependsOn = $Depends
}
}
}
if($Federation -and ($Node.NodeName -ieq $PrimaryServerMachine))
{
if(($AllNodes | Where-Object { ($_.Role -icontains 'ServerWebAdaptor') -or ($_.Role -icontains 'PortalWebAdaptor')} | Measure-Object).Count -eq 0)
{
if($PrimaryPortalMachine)
{
if($PrimaryServerMachine -ine $PrimaryPortalMachine)
{
$PortalHostName = Get-FQDN $PrimaryPortalMachine
$PortalPort = 7443
$PortalContext = "arcgis"
if($Node.WMFVersion -gt 4){
WaitForAll "WaitForAllPortalConfigToCompleteServerFederation$($PrimaryPortalMachine)"{
ResourceName = "[ArcGIS_Portal]Portal$($PrimaryPortalMachine)"
NodeName = $PrimaryPortalMachine
RetryIntervalSec = 60
RetryCount = 60
DependsOn = $Depends
}
$Depends += "[WaitForAll]WaitForAllPortalConfigToCompleteServerFederation$($PrimaryPortalMachine)"
}else{
ArcGIS_WaitForComponent "WaitForPortalConfigToCompleteServerFederation$($PrimaryPortalMachine)"{
Component = "Portal"
InvokingComponent = "Server"
ComponentHostName = $PortalHostName
ComponentContext = $PortalContext
Ensure = "Present"
Credential = $PSACredential
RetryIntervalSec = 60
RetryCount = 60
DependsOn = $Depends
}
$Depends += "[ArcGIS_WaitForComponent]WaitForPortalConfigToCompleteServerFederation$($PrimaryPortalMachine)"
}
}
else
{
Write-Verbose "Federation happens in primary portal machine"
}
}
else
{
$PortalHostName = $ConfigurationData.ConfigData.Federation.PortalHostName
$PortalPort = $ConfigurationData.ConfigData.Federation.PortalPort
$PortalContext = $ConfigurationData.ConfigData.Federation.PortalContext
$PortalFedPSAPassword = ConvertTo-SecureString $ConfigurationData.ConfigData.Federation.PrimarySiteAdmin.Password -AsPlainText -Force
$PortalFedPSACredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ($ConfigurationData.ConfigData.Federation.PrimarySiteAdmin.UserName, $PortalFedPSAPassword )
}
}
elseif(($AllNodes | Where-Object { ($_.Role -icontains 'ServerWebAdaptor') -or ($_.Role -icontains 'PortalWebAdaptor')} | Measure-Object).Count -gt 0)
{
if(($AllNodes | Where-Object { ($_.Role -icontains 'PortalWebAdaptor')} | Measure-Object).Count -gt 0)
{
if(-not(($AllNodes | Where-Object { ($_.Role -icontains 'ServerWebAdaptor')} | Measure-Object).Count -gt 0))
{
$PortalWAMachineName = ($AllNodes | Where-Object { ($_.Role -icontains 'PortalWebAdaptor')} | Select-Object -First 1).NodeName
$PortalHostName = (Get-FQDN $PortalWAMachineName)
$PortalPort = 443
$PortalContext = $ConfigurationData.ConfigData.PortalContext
if($Node.WMFVersion -gt 4){
WaitForAll "WaitForAllWebadaptorPortalConfigFederation$($PortalWAMachineName)"{
ResourceName = "[ArcGIS_WebAdaptor]ConfigurePortal$($PortalHostName)"
NodeName = $PortalWAMachineName
RetryIntervalSec = 60
RetryCount = 60
DependsOn = $Depends
}
$Depends += "[WaitForAll]WaitForAllPortalConfigToCompleteServerFederation$($PortalWAMachineName)"
}else{
ArcGIS_WaitForComponent "WaitForWebadaptorPortalConfigFederation$($PortalWAMachineName)"
{
Component = "PortalWA"
InvokingComponent = "Server"
ComponentHostName = $PortalHostName
ComponentContext = $PortalContext
Ensure = "Present"
Credential = $PSACredential
RetryIntervalSec = 60
RetryCount = 60
DependsOn = $Depends
}
$Depends += "[ArcGIS_WaitForComponent]WaitForWebadaptorPortalConfigFederation$($PortalWAMachineName)"
}
}
}
}
if($PortalHostName -and $PortalPort -and $PortalContext )
{
$FederationFlag = $True
if($HostingServer)
{
if($PrimaryDataStore)
{
if($Node.WMFVersion -gt 4){
WaitForAll "WaitForAllDataStoreInServer$($PrimaryDataStore)"{
ResourceName = "[ArcGIS_DataStore]DataStore$($PrimaryDataStore)"
NodeName = $PrimaryDataStore
RetryIntervalSec = 60
RetryCount = 100
DependsOn = $Depends
}
$Depends += "[WaitForAll]WaitForAllDataStoreInServer$($PrimaryDataStore)"
}else{
ArcGIS_WaitForComponent "WaitForDataStoreInServer$($PrimaryDataStore)"
{
Component = "DataStore"
InvokingComponent = "Server"
ComponentHostName = (Get-FQDN $PrimaryServerMachine)
ComponentContext = "arcgis"
Ensure = "Present"
Credential = $PSACredential
RetryIntervalSec = 60
RetryCount = 100
DependsOn = $Depends
}
$Depends += "[ArcGIS_WaitForComponent]WaitForDataStoreInServer$($PrimaryDataStore)"
}
}
else
{
$FederationFlag = $False
}
}
if($FederationFlag)
{
if($ConfigurationData.ConfigData.Server.SslCertifcate.Alias)
{
$ServerFedHostName = $ConfigurationData.ConfigData.Server.SslCertifcate.Alias
}
else
{
$ServerFedHostName = $MachineFQDN
}
if($ConfigurationData.ConfigData.Portal.SslCertifcate.Alias)
{
$PortalFEDHostName = $ConfigurationData.ConfigData.Portal.SslCertifcate.Alias
}
else
{
$PortalFEDHostName = $PortalHostName
}
ArcGIS_Federation FederateInServer
{
PortalHostName = $PortalFEDHostName
PortalPort = $PortalPort
PortalContext = $PortalContext
ServiceUrlHostName = $ServerFedHostName
ServiceUrlContext = 'arcgis'
ServiceUrlPort = 6443
ServerSiteAdminUrlHostName = $ServerFedHostName
ServerSiteAdminUrlPort = 6443
ServerSiteAdminUrlContext ='arcgis'
Ensure = "Present"
RemoteSiteAdministrator = if($PortalFedPSACredential){$PortalFedPSACredential}else{$PSACredential}
SiteAdministrator = $PSACredential
ServerRole = if($HostingServer){'HOSTING_SERVER'}else{'FEDERATED_SERVER'}
ServerFunctions = $ConfigurationData.ConfigData.ServerRole
DependsOn = $Depends
}
}
}
}
}
}
'Portal'{
$Depends = @()
if(-not($ConfigurationData.ConfigData.Credentials.ServiceAccount.IsDomainAccount)){
$Depends += '[User]ArcGIS_RunAsAccount'
}
$IsMultiMachinePortal = (($AllNodes | Where-Object { $_.Role -icontains 'Portal' } | Measure-Object).Count -gt 1)
if($IsMultiMachinePortal -or ($ConfigData.PortalEndPoint -as [ipaddress]))
{
xFirewall Portal_FirewallRules
{
Name = "PortalforArcGIS"
DisplayName = "Portal for ArcGIS"
DisplayGroup = "Portal for ArcGIS"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("7080","7443","7654")
Protocol = "TCP"
}
$Depends += @('[xFirewall]Portal_FirewallRules')
}
else
{ # If single machine, need to open 7443 to allow federation over private portal URL and 6443 for changeServerRole
xFirewall Portal_FirewallRules
{
Name = "PortalforArcGIS"
DisplayName = "Portal for ArcGIS"
DisplayGroup = "Portal for ArcGIS"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("7443")
Protocol = "TCP"
}
xFirewall ServerFederation_FirewallRules
{
Name = "ArcGISforServer-Federation"
DisplayName = "ArcGIS for Server"
DisplayGroup = "ArcGIS for Server"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("6443")
Protocol = "TCP"
}
}
if($IsMultiMachinePortal)
{
xFirewall Portal_Database_OutBound
{
Name = "PortalforArcGIS-Outbound"
DisplayName = "Portal for ArcGIS Outbound"
DisplayGroup = "Portal for ArcGIS Outbound"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
RemotePort = ("7654","7120","7220", "7005", "7099", "7199", "5701", "5702") # Elastic Search uses 7120,7220 and Postgres uses 7654 for replication, Hazelcast uses 5701 and 5702 (extra 2 ports for situations where unable to get port)
Direction = "Outbound"
Protocol = "TCP"
}
$Depends += @('[xFirewall]Portal_Database_OutBound')
xFirewall Portal_Database_InBound
{
Name = "PortalforArcGIS-Inbound"
DisplayName = "Portal for ArcGIS Inbound"
DisplayGroup = "Portal for ArcGIS Inbound"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("7120","7220", "5701", "5702") # Elastic Search uses 7120,7220, Hazelcast uses 5701 and 5702
Protocol = "TCP"
}
$Depends += @('[xFirewall]Portal_Database_InBound')
}
Service Portal_for_ArcGIS_Service
{
Name = 'Portal for ArcGIS'
Credential = $SACredential
StartupType = 'Automatic'
State = 'Running'
DependsOn = $Depends
}
$Depends += @('[Service]Portal_for_ArcGIS_Service')
$ContentDirectoryLocation = $ConfigurationData.ConfigData.Portal.ContentDirectoryLocation
if($FileShareMachine -and $ConfigurationData.ConfigData.FileShareName)
{
#$ContentDirectoryLocation = "\\$($FileShareMachine)\$($ConfigurationData.ConfigData.FileShareName)\$($ConfigurationData.ConfigData.Portal.ContentDirectoryLocation)"
$FilePathsForPortal = @()
$FilePathsForPortal += $ContentDirectoryLocation
if($ConfigurationData.ConfigData.Credentials.ServiceAccount.IsDomainAccount){
$FileShareCredential = $SACredential
}else{
$FileShareCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ("$FileShareMachine\$($ConfigurationData.ConfigData.Credentials.ServiceAccount.UserName)", $SAPassword )
}
if($Node.WMFVersion -gt 4){
WaitForAll "WaitForAllFileSharePortal$($Node.NodeName)"{
ResourceName = "[ArcGIS_FileShare]FileShare"
NodeName = $FileShareMachine
RetryIntervalSec = 20
RetryCount = 30
DependsOn = $Depends
}
$Depends += "[WaitForAll]WaitForAllFileSharePortal$($Node.NodeName)"
}else{
ArcGIS_WaitForFileShare "WaitForFileSharePortal$($Node.NodeName)"{
FilePaths = ($FilePathsForPortal -join ',')
Ensure = "Present"
RetryIntervalSec = 20
RetryCount = 30
Credential = $FileShareCredential
DependsOn = $Depends
}
$Depends += "[ArcGIS_WaitForFileShare]WaitForFileSharePortal$($Node.NodeName)"
}
}
$DataDirsForPortal = @('HKLM:\SOFTWARE\ESRI\Portal for ArcGIS')
if($ContentDirectoryLocation -and (-not($ContentDirectoryLocation.StartsWith('\'))))
{
$DataDirsForPortal += $ContentDirectoryLocation
$DataDirsForPortal += (Split-Path $ContentDirectoryLocation -Parent)
File ContentDirectoryLocation
{
Ensure = "Present"
DestinationPath = $ContentDirectoryLocation
Type = 'Directory'
DependsOn = $Depends
}
$Depends += "[File]ContentDirectoryLocation"
}
ArcGIS_Service_Account Portal_RunAs_Account
{
Name = 'Portal for ArcGIS'
RunAsAccount = $SACredential
Ensure = "Present"
DataDir = $DataDirsForPortal
DependsOn = $Depends
}
$Depends += @('[ArcGIS_Service_Account]Portal_RunAs_Account')
$HasLoadBalancer = (($AllNodes | Where-Object { $_.Role -icontains 'LoadBalancer' } | Measure-Object).Count -gt 0)
$ExternalDNSName = [System.Net.DNS]::GetHostByName($PrimaryPortalMachine).HostName
if($ConfigurationData.ConfigData.Portal.SslCertifcate)
{
$ExternalDNSName = $ConfigurationData.ConfigData.Portal.SslCertifcate.Alias
}
else
{
if($HasLoadBalancer)
{
$LBMachine = ($AllNodes | Where-Object { $_.Role -icontains 'LoadBalancer' }| Sort-Object | Select-Object -First 1).NodeName
$ExternalDNSName = [System.Net.DNS]::GetHostByName($LBMachine).HostName
}
else
{
if((($AllNodes | Where-Object { ($_.Role -icontains 'PortalWebAdaptor')} | Measure-Object).Count -gt 0) -and $ConfigurationData.ConfigData.PortalContext)
{
$PortalWAMachine = ($AllNodes | Where-Object { ($_.Role -icontains 'PortalWebAdaptor') }| Select-Object -First 1).NodeName
$ExternalDNSName = [System.Net.DNS]::GetHostByName($PortalWAMachine).HostName
}
}
}
if($Node.NodeName -ine $PrimaryPortalMachine)
{
if($Node.WMFVersion -gt 4){
WaitForAll "WaitForAllPortal$($PrimaryPortalMachine)"{
ResourceName = "[ArcGIS_Portal]Portal$($PrimaryPortalMachine)"
NodeName = $PrimaryPortalMachine
RetryIntervalSec = 60
RetryCount = 90
DependsOn = $Depends
}
$Depends += "[WaitForAll]WaitForAllPortal$($PrimaryPortalMachine)"
}else{
ArcGIS_WaitForComponent "WaitForPortal$($PrimaryPortalMachine)"
{
Component = "Portal"
InvokingComponent = "Portal"
ComponentHostName = (Get-FQDN $PrimaryPortalMachine)
ComponentContext = "arcgis"
Ensure = "Present"
Credential = $PSACredential
RetryIntervalSec = 60
RetryCount = 90
DependsOn = $Depends
}
$Depends += "[ArcGIS_WaitForComponent]WaitForPortal$($PrimaryPortalMachine)"
}
}
ArcGIS_Portal "Portal$($Node.NodeName)"
{
Ensure = 'Present'
PortalContext = $ConfigurationData.ConfigData.PortalContext
PortalAdministrator = $PSACredential
DependsOn = $Depends
AdminEMail = $ConfigurationData.ConfigData.Credentials.PrimarySiteAdmin.Email
AdminSecurityQuestionIndex = 1
AdminSecurityAnswer = "vanilla"
ContentDirectoryLocation = $ContentDirectoryLocation
Join = if($Node.NodeName -ine $PrimaryPortalMachine) { $true } else { $false }
IsHAPortal = if($IsMultiMachinePortal){$True}else{$False}
ExternalDNSName = $ExternalDNSName
PortalEndPoint = $MachineFQDN
PeerMachineHostName = if($Node.NodeName -ine $PrimaryPortalMachine) { (Get-FQDN $PrimaryPortalMachine) } else { "" }
EnableDebugLogging = $True
}
if($Node.NodeName -ieq $PrimaryPortalMachine -and (($AllNodes | Where-Object { ($_.Role -icontains 'LoadBalancer')} | Measure-Object).Count -eq 0))
{
if(($AllNodes | Where-Object { ($_.Role -icontains 'PortalWebAdaptor')} | Measure-Object).Count -eq 0)
{
if($ConfigurationData.ConfigData.Portal.SslCertifcate.Alias)
{
ArcGIS_Portal_TLS "Portal_TLS$($Node.NodeName)"
{
Ensure = $Ensure
SiteName = $PortalContext
SiteAdministrator = $PSACredential
CName = $ConfigurationData.ConfigData.Portal.SslCertifcate.Alias
CertificateFileLocation = $ConfigurationData.ConfigData.Portal.SslCertifcate.Path
CertificatePassword = $ConfigurationData.ConfigData.Portal.SslCertifcate.Password
DependsOn = @("[ArcGIS_Portal]Portal$($Node.NodeName)")
}
}
}
if($Federation -and (($AllNodes | Where-Object { ($_.Role -icontains 'ServerWebAdaptor') -or ($_.Role -icontains 'PortalWebAdaptor')} | Measure-Object).Count -eq 0))
{
if($PrimaryPortalMachine)
{
if($PrimaryServerMachine -ieq $PrimaryPortalMachine)
{
$PortalHostName = Get-FQDN $PrimaryPortalMachine
$PortalPort = 7443
$PortalContext = 'arcgis'