-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathset-Office365DL.ps1
1283 lines (996 loc) · 57.6 KB
/
set-Office365DL.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
<#
.SYNOPSIS
This function sets the single value attributes of the group created in Office 365.
.DESCRIPTION
This function sets the single value attributes of the group created in Office 365.
.PARAMETER originalDLConfiguration
The original configuration of the DL on premises.
.PARAMETER groupTypeOverride
Submits the group type override of specified by the administrator at run time.
.OUTPUTS
None
.EXAMPLE
set-Office365DL -originalDLConfiguration DLConfiguration -groupTypeOverride TYPEOVERRIDE -office365DLConfigurationPostMigration OFFICE365DLCONFIGURATION
#>
Function set-Office365DL
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory = $true)]
$originalDLConfiguration,
[Parameter(Mandatory = $true)]
$office365DLConfiguration,
[Parameter(Mandatory = $true)]
[string]$groupTypeOverride,
[Parameter(Mandatory = $true)]
$office365DLConfigurationPostMigration,
[Parameter(Mandatory=$FALSE)]
[boolean]$isFirstAttempt=$false,
[Parameter(Mandatory=$FALSE)]
[string]$prefix="",
[Parameter(Mandatory=$FALSE)]
[string]$suffix=""
)
#Output all parameters bound or unbound and their associated values.
write-functionParameters -keyArray $MyInvocation.MyCommand.Parameters.Keys -parameterArray $PSBoundParameters -variableArray (Get-Variable -Scope Local -ErrorAction Ignore)
#Declare function variables.
$functionModerationFlags=$NULL
$functionSendModerationNotifications=$NULL
$functionModerationEnabled=$NULL
$functionoofReplyToOriginator=$NULL
$functionreportToOwner=$NULL
$functionHiddenFromAddressList=$NULL
$functionMemberJoinRestriction=$NULL
$functionMemberDepartRestriction=$NULL
$functionRequireAuthToSendTo=$NULL
[string]$functionMailNickName=""
[string]$functionDisplayName=""
[string]$functionSimpleDisplayName=""
[string]$functionWindowsEmailAddress=""
[boolean]$functionReportToOriginator=$FALSE
[string]$functionExternalDirectoryObjectID = ""
[string]$functionDLName = ""
[boolean]$isTestError=$FALSE
[array]$functionErrors=@()
#Start function processing.
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "BEGIN SET-Office365DL"
Out-LogFile -string "********************************************************************************"
out-logfile -string "Modifying name with prefix and suffix."
$functionDLName = $prefix + $originalDLConfiguration.name + $suffix
out-logfile -string ("Calculated DL Name including prefix and suffix: "+$functionDLName)
if ($office365DLConfigurationPostMigration.externalDirectoryObjectID -eq "")
{
$functionExternalDirectoryObjectID = $office365DLConfigurationPostMigration.GUID
}
else
{
$functionExternalDirectoryObjectID = $office365DLConfigurationPostMigration.externalDirectoryObjectID
}
out-logfile -string "Setting core single values for the distribution group."
out-logfile -string "Determining if this is the first pass on attribute setting."
if ($isFirstAttempt -eq $FALSE)
{
out-logfile -string "This is not the first pass - set attribute that may collide with the original group."
try
{
out-logfile -string "Setting distribution group name for the migrated group."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -name $functionDLName -errorAction STOP -BypassSecurityGroupManagerCheck
}
catch
{
out-logfile "Error encountered setting core single valued attributes."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $functionDLName+" ("+$originalDLConfiguration.name+")"
Attribute = "Cloud distribution list: Name"
ErrorMessage = "Error setting name on the migrated distribution group. Administrator action required."
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting distribution windows email address."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -WindowsEmailAddress $originalDLConfiguration.mail -errorAction STOP -BypassSecurityGroupManagerCheck
}
catch
{
out-logfile "Error encountered setting core single valued attributes."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: WindowsEmailAddress"
ErrorMessage = "Error setting windows email address on the migrated distribution group. Administrator action required."
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
}
else
{
out-logfile -string "This is the first pass set attribute that would not collide with the original group."
#There are several flags of a DL that are either calculated hashes <or> booleans not set by default.
#The exchange commandlets abstract this by performing a conversion or filling the values in.
#Since we use ldap to get these values now - we must reverse engineer these and / or set them.
#If the group type was overridden from the default - the member join restriction has to be adjusted.
#If the group tyoe was not overriden - check to see if depart is NULL and set to closed which is default.
#Otherwise take the value from the string.
if ( $groupTypeOverride -eq "Security" )
{
out-logfile -string "Group type overridden to Security by administrator. This requires depart restriction closed."
$functionMemberDepartRestriction = "Closed"
out-logfile -string ("Function member depart restrictions = "+$functionMemberDepartRestriction)
}
elseif ($originalDLConfiguration.msExchGroupDepartRestriction -eq $NULL)
{
out-logFile -string ("Member depart restriction is NULL.")
$functionMemberDepartRestriction="Closed"
out-LogFile -string ("The member depart restriction is now = "+$functionMemberDepartRestriction)
}
elseif (($originalDLConfiguration.groupType -eq "-2147483640") -or ($originalDLConfiguration.groupType -eq "-2147483646") -or ($originalDLConfiguration.groupType -eq "-2147483644"))
{
Out-logfile -string ("Group type is security - ensuring member depart restriction CLOSED")
$functionMemberDepartRestriction="Closed"
}
else
{
$functionMemberDepartRestriction = $originalDLConfiguration.msExchGroupDepartRestriction
out-logfile -string ("Function member depart restrictions = "+$functionMemberDepartRestriction)
}
#The moderation settings a are a hash valued flag.
#This test looks to see if bypass nested moderation is enabled from the hash.
if (($originalDLConfiguration.msExchModerationFlags -eq "1") -or ($originalDLConfiguration.msExchModerationFlags -eq "3") -or ($originalDLConfiguration.msExchModerationFlags -eq "7") )
{
out-logfile -string ("The moderation flags are 1 / 3 / 7 - setting bypass nested moderation to TRUE - "+$originalDLConfiguration.msExchModerationFlags)
$functionModerationFlags=$TRUE
out-logfile ("The function moderation flags are = "+$functionModerationFlags)
}
else
{
out-logfile -string ("The moderation flags are NOT 1 / 3 / 7 - setting bypass nested moderation to FALSE - "+$originalDLConfiguration.msExchModerationFlags)
$functionModerationFlags=$FALSE
out-logfile ("The function moderation flags is = "+$functionModerationFlags)
}
#Test now to see if the moderation settings are always, internal, or none. This uses the same hash.
if (($originalDLConfiguration.msExchModerationFlags -eq "0") -or ($originalDLConfiguration.msExchModerationFlags -eq "1") )
{
out-logfile -string ("The moderation flags are 0 / 2 / 6 - send notifications to never."+$originalDLConfiguration.msExchModerationFlags)
$functionSendModerationNotifications="Never"
out-logfile -string ("The function send moderation notifications is = "+$functionSendModerationNotifications)
}
elseif (($originalDLConfiguration.msExchModerationFlags -eq "2") -or ($originalDLConfiguration.msExchModerationFlags -eq "3") )
{
out-logfile -string ("The moderation flags are 0 / 2 / 6 - setting send notifications to internal."+$originalDLConfiguration.msExchModerationFlags)
$functionSendModerationNotifications="Internal"
out-logfile -string ("The function send moderation notifications is = "+$functionSendModerationNotifications)
}
elseif (($originalDLConfiguration.msExchModerationFlags -eq "6") -or ($originalDLConfiguration.msExchModerationFlags -eq "7") )
{
out-logfile -string ("The moderation flags are 0 / 2 / 6 - setting send notifications to always."+$originalDLConfiguration.msExchModerationFlags)
$functionSendModerationNotifications="Always"
out-logfile -string ("The function send moderation notifications is = "+$functionSendModerationNotifications)
}
else
{
out-logFile -string ("The moderation flags are not set. Setting to default of always.")
$functionSendModerationNotifications="Always"
out-logFile -string ("The function send moderation notification is = "+$functionSendModerationNotifications)
}
#Evaluate moderation enabled.
if ($originalDLConfiguration.msExchEnableModeration -eq $NULL)
{
out-logfile -string "The moderation enabled setting is null."
$functionModerationEnabled=$FALSE
out-logfile -string ("The updated moderation enabled flag is = "+$functionModerationEnabled)
}
else
{
out-logfile -string "The moderation setting was set on premises."
$functionModerationEnabled=$originalDLConfiguration.msExchEnableModeration
out-Logfile -string ("The function moderation setting is "+$functionModerationEnabled)
}
#Evaluate oofReplyToOriginator
if ($originalDLConfiguration.oofReplyToOriginator -eq $NULL)
{
out-logfile -string "The oofReplyToOriginator is null."
$functionoofReplyToOriginator = $FALSE
out-logfile -string ("The oofReplyToOriginator is now = "+$functionoofReplyToOriginator)
}
else
{
out-logFile -string "The oofReplyToOriginator was set on premises."
$functionoofReplyToOriginator=$originalDLConfiguration.oofReplyToOriginator
out-logfile -string ("The function oofReplyToOriginator = "+$functionoofReplyToOriginator)
}
#Evaluate reportToOwner
if ($originalDLConfiguration.reportToOwner -eq $NULL)
{
out-logfile -string "The reportToOwner is null."
$functionreportToOwner = $FALSE
out-logfile -string ("The reportToOwner is now = "+$functionreportToOwner)
}
else
{
out-logfile -string "The reportToOwner was set on premises."
$functionReportToOwner = $originalDLConfiguration.reportToOwner
out-logfile -string ("The function reportToOwner = "+$functionreportToOwner)
}
if ($originalDLConfiguration.reportToOriginator -eq $NULL)
{
out-logfile -string "The report to originator is NULL."
$functionReportToOriginator = $FALSE
}
else
{
$functionReportToOriginator = $originalDLConfiguration.reportToOriginator
}
#Evaluate hidden from address list.
if ($originalDLConfiguration.msExchHideFromAddressLists -eq $NULL)
{
out-logfile -string ("Hidden from address list is null.")
$functionHiddenFromAddressList=$FALSE
out-logfile -string ("The hidden from address list is now = "+$functionHiddenFromAddressList)
}
else
{
out-logFile -string ("Hidden from address list is not null.")
$functionHiddenFromAddressList=$originalDLConfiguration.msExchHideFromAddressLists
}
#Evaluate member join restrictions.
if ($originalDLConfiguration.msExchGroupJoinRestriction -eq $NULL)
{
out-Logfile -string ("Member join restriction is NULL.")
$functionMemberJoinRestriction="Closed"
out-logfile -string ("The member join restriction is now = "+$functionMemberJoinRestriction)
}
else
{
$functionMemberJoinRestriction = $originalDLConfiguration.msExchGroupJoinRestriction
out-logfile -string ("The function member join restriction is: "+$functionMemberJoinRestriction)
}
#Evaluate require auth to send to DL. If the DL is open to everyone - the value may not be present.
if ($originalDLConfiguration.msExchRequireAuthToSendTo -eq $NULL)
{
out-logfile -string ("Require auth to send to is not set.")
$functionRequireAuthToSendTo = $FALSE
out-logfile -string ("The new require auth to sent to is: "+$functionRequireAuthToSendTo)
}
else
{
out-logfile -string ("Require auth to send to is set - retaining value. "+ $originalDLConfiguration.msExchRequireAuthToSendTo)
$functionRequireAuthToSendTo = $originalDLConfiguration.msExchRequireAuthToSendTo
}
#It is possible that the group is not fully mail enabled.
#Groups may now be represented as mail enabled if only MAIL is populated.
#If on premsies attributes are not specified - use the attributes that were obtained from office 365.
if ($originalDLConfiguration.mailNickName -eq $NULL)
{
out-logfile -string "On premises group does not have alias / mail nick name -> using Office 365 value."
$functionMailNickName = $office365DLConfiguration.alias
out-logfile -string ("Office 365 alias used for group creation: "+$functionMailNickName)
}
else
{
out-logfile -string "On premises group has a mail nickname specified - using on premises value."
$functionMailNickName = $originalDLConfiguration.mailNickName
out-logfile -string $functionMailNickName
}
if ($originalDLConfiguration.displayName -ne $NULL)
{
$functionDisplayName = $originalDLConfiguration.displayName
}
else
{
$functionDisplayName = $office365DLConfiguration.displayName
}
out-logfile -string "Evaluating prefix and suffix for display name."
$functionDisplayname = $prefix + $functionDisplayName
out-logfile -string ("Display name with prefix: "+$functionDisplayName)
$functionDisplayName = $functionDisplayName +$suffix
out-logfile -string ("Display name with suffix: "+$functionDisplayName)
if ($originalDLConfiguration.DisplayNamePrintable -ne $NULL)
{
$functionSimpleDisplayName = $originalDLConfiguration.displayNamePrintable
}
else
{
$functionSimpleDisplayName = $office365DLConfiguration.simpleDisplayName
}
try
{
out-logfile -string "Setting distribution group alias."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -Alias $functionMailNickName -errorAction STOP -BypassSecurityGroupManagerCheck
}
catch
{
out-logfile "Error encountered setting core single valued attributes."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: Alias"
ErrorMessage = "Error setting alias on the migrated distribution group. Administrator action required."
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting distribution group display name."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -DisplayName $functionDisplayName -errorAction STOP -BypassSecurityGroupManagerCheck
}
catch
{
out-logfile "Error encountered setting core single valued attributes."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: DisplayName"
ErrorMessage = "Error setting display name on the migrated distribution group. Administrator action required."
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting distribution group hidden from address list."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -HiddenFromAddressListsEnabled $functionHiddenFromAddressList -errorAction STOP -BypassSecurityGroupManagerCheck
}
catch
{
out-logfile "Error encountered setting core single valued attributes."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: HiddenFromAddressListsEnabled"
ErrorMessage = "Error setting hide from address book on the migrated distribution group. Administrator action required."
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting distribution group require sender authentication enabled."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -RequireSenderAuthenticationEnabled $functionRequireAuthToSendTo -errorAction STOP -BypassSecurityGroupManagerCheck
}
catch
{
out-logfile "Error encountered setting core single valued attributes."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: RequireAuthenticationEnabled"
ErrorMessage = "Error setting require sender authentication on the migrated distribution group. Administrator action required."
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting distribution group simple display name."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -SimpleDisplayName $functionSimpleDisplayName -errorAction STOP -BypassSecurityGroupManagerCheck
}
catch
{
out-logfile "Error encountered setting core single valued attributes."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: SimpleDisplayName"
ErrorMessage = "Error setting simple display name on the migrated distribution group. Administrator action required."
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting mail tip translations."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -MailTipTranslations $originalDLConfiguration.msExchSenderHintTranslations -errorAction STOP -BypassSecurityGroupManagerCheck
}
catch
{
out-logfile "Error encountered setting core single valued attributes."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: MailTipTranslations"
ErrorMessage = "Error setting mail tip translations on the migrated distribution group. Administrator action required."
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
out-logfile -string "Setting single valued moderation properties for the group."
try
{
out-logfile -string "Setting bypass nested moderation enabled."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -BypassNestedModerationEnabled $functionModerationFlags -errorAction STOP -BypassSecurityGroupManagerCheck
}
catch
{
out-logfile "Error encountered setting moderation properties of the group...."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: BypassNestedModerationEnabled"
ErrorMessage = "Error setting bypass nested moderation enabled on the migrated distribution group. Administrator action required."
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting moderation enabled for the group."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -ModerationEnabled $functionModerationEnabled -errorAction STOP -BypassSecurityGroupManagerCheck
}
catch
{
out-logfile "Error encountered setting moderation properties of the group...."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: ModerationEnabled"
ErrorMessage = "Error setting moderation enabled on the migrated distribution group. Administrator action required."
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting send moderation notifications for the group."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -SendModerationNotifications $functionSendModerationNotifications -errorAction STOP -BypassSecurityGroupManagerCheck
}
catch
{
out-logfile "Error encountered setting moderation properties of the group...."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: SendModerationNotifications"
ErrorMessage = "Error setting send moderation notifications on the migrated distribution group. Administrator action required."
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
out-logfile -string "Setting member join and depart restrictions on the group."
try
{
out-logfile -string "Setting member join restrictions on the group.."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -MemberJoinRestriction $functionMemberJoinRestriction -errorAction STOP -BypassSecurityGroupManagerCheck
}
catch
{
out-logfile "Error encountered setting member join depart restritions on the group...."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: MemberJoinRestriction"
ErrorMessage = "Error setting member join restriction on the group. Administrator action required"
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting member depart restrictions on the group.."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -MemberDepartRestriction $functionMemberDepartRestriction -errorAction STOP -BypassSecurityGroupManagerCheck
}
catch
{
out-logfile "Error encountered setting member join depart restritions on the group...."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: MemberDepartRestriction"
ErrorMessage = "Error setting member depart restriction on the group. Administrator action required"
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
out-logfile -string "Setting the single valued report to settings.."
try
{
out-logfile -string "Setting the report to manager enabled.."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -ReportToManagerEnabled $functionreportToOwner -BypassSecurityGroupManagerCheck -errorAction STOP
}
catch
{
out-logfile "Error encountered setting single valued report to settings on the group...."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: ReportToManagerEnabled"
ErrorMessage = "Error setting report to manager enabled. Administrator action required."
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting the report to originator enabled.."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -ReportToOriginatorEnabled $functionReportToOriginator -BypassSecurityGroupManagerCheck -errorAction STOP
}
catch
{
out-logfile "Error encountered setting single valued report to settings on the group...."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: ReporToOriginatorEnabled"
ErrorMessage = "Error setting report to originator enabled. Administrator action required."
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting the send oof messages to originator enabled.."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -SendOofMessageToOriginatorEnabled $functionoofReplyToOriginator -BypassSecurityGroupManagerCheck -errorAction STOP
}
catch
{
out-logfile "Error encountered setting single valued report to settings on the group...."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: SendOOFMessagesToOriginatorEnabled"
ErrorMessage = "Error setting send off messages to originator enabled. Administrator action required."
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
out-logfile -string "Setting the custom and extension attributes of the group."
try
{
out-logfile -string "Setting extension attribute 1 of the group."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -CustomAttribute1 $originalDLConfiguration.extensionAttribute1 -BypassSecurityGroupManagerCheck -errorAction STOP
}
catch
{
out-logfile "Error encountered setting custom and extension attributes of the group...."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: CustomAttribute1"
ErrorMessage = "Error setting custom attribute 1. Administrator action required"
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting extension attribute 10 of the group."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -CustomAttribute10 $originalDLConfiguration.extensionAttribute10 -BypassSecurityGroupManagerCheck -errorAction STOP
}
catch
{
out-logfile "Error encountered setting custom and extension attributes of the group...."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: CustomAttribute10"
ErrorMessage = "Error setting custom attribute 10. Administrator action required"
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting extension attribute 11 of the group."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -CustomAttribute11 $originalDLConfiguration.extensionAttribute11 -BypassSecurityGroupManagerCheck -errorAction STOP
}
catch
{
out-logfile "Error encountered setting custom and extension attributes of the group...."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: CustomAttribute11"
ErrorMessage = "Error setting custom attribute 11. Administrator action required"
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting extension attribute 12 of the group."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -CustomAttribute12 $originalDLConfiguration.extensionAttribute12 -BypassSecurityGroupManagerCheck -errorAction STOP
}
catch
{
out-logfile "Error encountered setting custom and extension attributes of the group...."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: CustomAttribute12"
ErrorMessage = "Error setting custom attribute 12. Administrator action required"
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting extension attribute 13 of the group."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -CustomAttribute13 $originalDLConfiguration.extensionAttribute13 -BypassSecurityGroupManagerCheck -errorAction STOP
}
catch
{
out-logfile "Error encountered setting custom and extension attributes of the group...."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: CustomAttribute13"
ErrorMessage = "Error setting custom attribute 13. Administrator action required"
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting extension attribute 14 of the group."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -CustomAttribute14 $originalDLConfiguration.extensionAttribute14 -BypassSecurityGroupManagerCheck -errorAction STOP
}
catch
{
out-logfile "Error encountered setting custom and extension attributes of the group...."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: CustomAttribute14"
ErrorMessage = "Error setting custom attribute 14. Administrator action required"
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting extension attribute 1 of the group."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -CustomAttribute15 $originalDLConfiguration.extensionAttribute15 -BypassSecurityGroupManagerCheck -errorAction STOP
}
catch
{
out-logfile "Error encountered setting custom and extension attributes of the group...."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: CustomAttribute15"
ErrorMessage = "Error setting custom attribute 15. Administrator action required"
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting extension attribute 2 of the group."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -CustomAttribute2 $originalDLConfiguration.extensionAttribute2 -BypassSecurityGroupManagerCheck -errorAction STOP
}
catch
{
out-logfile "Error encountered setting custom and extension attributes of the group...."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: CustomAttribute2"
ErrorMessage = "Error setting custom attribute 2. Administrator action required"
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}
try
{
out-logfile -string "Setting extension attribute 3 of the group."
Set-O365DistributionGroup -Identity $functionExternalDirectoryObjectID -CustomAttribute3 $originalDLConfiguration.extensionAttribute3 -BypassSecurityGroupManagerCheck -errorAction STOP
}
catch
{
out-logfile "Error encountered setting custom and extension attributes of the group...."
out-logfile -string $_
$isErrorObject = new-Object psObject -property @{
PrimarySMTPAddressorUPN = $originalDLConfiguration.mail
ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
Alias = $functionMailNickName
Name = $originalDLConfiguration.name
Attribute = "Cloud distribution list: CustomAttribute3"
ErrorMessage = "Error setting custom attribute 3. Administrator action required"
ErrorMessageDetail = $_
}
$functionErrors+=$isErrorObject
}