-
Notifications
You must be signed in to change notification settings - Fork 0
/
ContactConversionV1.psm1
4107 lines (3290 loc) · 164 KB
/
ContactConversionV1.psm1
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
#############################################################################################
# DISCLAIMER: #
# #
# THE SAMPLE SCRIPTS ARE NOT SUPPORTED UNDER ANY MICROSOFT STANDARD SUPPORT #
# PROGRAM OR SERVICE. THE SAMPLE SCRIPTS ARE PROVIDED AS IS WITHOUT WARRANTY #
# OF ANY KIND. MICROSOFT FURTHER DISCLAIMS ALL IMPLIED WARRANTIES INCLUDING, WITHOUT #
# LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR OF FITNESS FOR A PARTICULAR #
# PURPOSE. THE ENTIRE RISK ARISING OUT OF THE USE OR PERFORMANCE OF THE SAMPLE SCRIPTS #
# AND DOCUMENTATION REMAINS WITH YOU. IN NO EVENT SHALL MICROSOFT, ITS AUTHORS, OR #
# ANYONE ELSE INVOLVED IN THE CREATION, PRODUCTION, OR DELIVERY OF THE SCRIPTS BE LIABLE #
# FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS #
# PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) #
# ARISING OUT OF THE USE OF OR INABILITY TO USE THE SAMPLE SCRIPTS OR DOCUMENTATION, #
# EVEN IF MICROSOFT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES #
#############################################################################################
Function Start-ContactMigration
{
<#
.SYNOPSIS
This is the trigger function that begins the process of allowing an administrator to migrate a distribution list from
on premises to Office 365.
.DESCRIPTION
Trigger function.
.PARAMETER contactSMTPAddress
*REQUIRED*
The SMTP address of the distribution list to be migrated.
.PARAMETER globalCatalogServer
*REQUIRED*
A global catalog server in the domain where the contact to be migrated resides.
.PARAMETER activeDirectoryCredential
*REQUIRED*
This is the credential that will be utilized to perform operations against the global catalog server.
If the contact and all it's dependencies reside in a single domain - a domain administrator is acceptable.
If the contact and it's dependencies span multiple domains in a forest - enterprise administrator is required.
.PARAMETER logFolder
*REQUIRED*
The location where logging for the migration should occur including all XML outputs for backups.
.PARAMETER aadConnectServer
*OPTIONAL*
This is the AADConnect server that automated sycn attempts will be attempted.
If specified with an AADConnect credential - delta syncs will be triggered automatically in attempts to service the move.
This requires WINRM be enabled on the ADConnect server and may have additional WINRM dependencies / configuration.
Name should be specified in fully qualified domain format.
.PARAMETER aadConnectCredential
*OPTIONAL*
The credential specified to perform remote powershell / winrm sessions to the AADConnect server.
.PARAMETER exchangeOnlineCredential
*REQUIRED IF NO OTHER CREDENTIALS SPECIFIED*
This is the credential utilized for Exchange Online connections.
The credential must be specified if certificate based authentication is not configured.
The account requires global administration rights / exchange organization management rights.
An exchange online credential cannot be combined with an exchangeOnlineCertificateThumbprint.
.PARAMETER exchangeOnlineCertificateThumbprint
*REQUIRED IF NO OTHER CREDENTIALS SPECIFIED*
This is the certificate thumbprint that will be utilzied for certificate authentication to Exchange Online.
This requires all the pre-requists be established and configured prior to access.
A certificate thumbprint cannot be specified with exchange online credentials.
.PARAMETER doNoSyncOU
*REQUIRED IF RETAIN contact FALSE*
This is the administrator specified organizational unit that is NOT configured to sync in AD Connect.
When the administrator specifies to NOT retain the contact the contact is moved to this OU to allow for deletion from Office 365.
A doNOSyncOU must be specified if the administrator specifies to NOT retain the contact.
.PARAMETER retainOriginalContact
*OPTIONAL*
Allows the administrator to retain the contact - for example if the contact also has on premises security dependencies.
This triggers a mail disable of the contact resulting in contact deletion from Office 365.
The name of the contact is randomized with a character ! to ensure no conflict with hybird mail flow - if hybrid mail flow enabled.
.PARAMETER enableHybridMailFlow
*OPTIONAL*
Allows the administrator to decide that they want mail flow from on premises to cloud to work for the migrated contact.
This involves provisioning a mail contact and a dynamic distribution contact.
The dynamic distribution contact is intentionally choosen to prevent soft matching of a contact and an undo of the migration.
This option requires on premises Exchange be specified and configured.
.PARAMETER contactTypeOverride
*OPTIONAL*
This allows the administrator to override the contact type created in the cloud from on premises.
For example - if the contact was provisioned on premises as security but does not require security rights in Office 365 - the administrator can override to DISTRIBUTION.
Mandatory types -> SECURITY or DISTRIBUTION
.OUTPUTS
Logs all activities and backs up all original data to the log folder directory.
Moves the distribution contact from on premieses source of authority to office 365 source of authority.
.EXAMPLE
Start-DistributionListMigration
#>
[cmdletbinding()]
Param
(
[Parameter(Mandatory = $true)]
[string]$contactSMTPAddress,
[Parameter(Mandatory = $true)]
[string]$globalCatalogServer,
[Parameter(Mandatory = $true)]
[pscredential]$activeDirectoryCredential,
[Parameter(Mandatory = $true)]
[string]$logFolderPath,
[Parameter(Mandatory = $false)]
[string]$aadConnectServer=$NULL,
[Parameter(Mandatory = $false)]
[pscredential]$aadConnectCredential=$NULL,
[Parameter(Mandatory = $false)]
[pscredential]$exchangeOnlineCredential=$NULL,
[Parameter(Mandatory = $false)]
[string]$exchangeOnlineCertificateThumbPrint="",
[Parameter(Mandatory = $false)]
[string]$exchangeOnlineOrganizationName="",
[Parameter(Mandatory = $false)]
[ValidateSet("O365Default","O365GermanyCloud","O365China","O365USGovGCCHigh","O365USGovDoD")]
[string]$exchangeOnlineEnvironmentName="O365Default",
[Parameter(Mandatory = $false)]
[string]$exchangeOnlineAppID="",
[Parameter(Mandatory = $true)]
[string]$dnNoSyncOU = "NotSet",
[Parameter(Mandatory = $false)]
[boolean]$retainOriginalcontact = $TRUE,
[Parameter(Mandatory = $false)]
[int]$threadNumberAssigned=0,
[Parameter(Mandatory = $false)]
[int]$totalThreadCount=0,
[Parameter(Mandatory = $FALSE)]
[boolean]$isMultiMachine=$FALSE,
[Parameter(Mandatory = $FALSE)]
[string]$remoteDriveLetter=$NULL,
[Parameter(Mandatory=$false)]
[boolean]$allowNonSyncedcontact=$FALSE
)
$windowTitle = ("Start-ContactMigration"+$contactSMTPAddress)
$host.ui.RawUI.WindowTitle = $windowTitle
if ($isMultiMachine -eq $TRUE)
{
try{
#At this point we know that multiple machines was in use.
#For multiple machines - the local controller instance mapped the drive Z for us in windows.
#Therefore we override the original log folder path passed in and just use Z.
[string]$networkName=$remoteDriveLetter
$logFolderPath = $networkName+":"
}
catch{
exit
}
}
#Define global variables.
$global:threadNumber=$threadNumberAssigned
$global:logFile=$NULL #This is the global variable for the calculated log file name
[string]$global:staticFolderName="\contactMigration\"
[string]$global:staticAuditFolderName="\AuditData\"
[string]$global:importFile=$logFolderPath+$global:staticAuditFolderName
[int]$global:unDoStatus=0
[array]$importData=@()
[string]$importFilePath=$NULL
#Define variables utilized in the core function that are not defined by parameters.
[boolean]$useAADConnect=$FALSE #Determines if function will utilize aadConnect during migration.
[string]$aadConnectPowershellSessionName="AADConnect" #Defines universal name for aadConnect powershell session.
[string]$ADGlobalCatalogPowershellSessionName="ADGlobalCatalog" #Defines universal name for ADGlobalCatalog powershell session.
[string]$exchangeOnlinePowershellModuleName="ExchangeOnlineManagement" #Defines the exchage management shell name to test for.
[string]$activeDirectoryPowershellModuleName="ActiveDirectory" #Defines the active directory shell name to test for.
[string]$contactConversionPowershellModule="ContactConversionV1"
[string]$globalCatalogPort=":3268"
[string]$globalCatalogWithPort=$globalCatalogServer+$globalCatalogPort
#The variables below are utilized to define working parameter sets.
#Some variables are assigned to single values - since these will be utilized with functions that query or set information.
[string]$acceptMessagesFromcontactMembers="dlMemSubmitPerms" #Attribute for the allow email members.
[string]$rejectMessagesFromcontactMembers="dlMemRejectPerms"
[string]$bypassModerationFromcontact="msExchBypassModerationLink"
[string]$bypassModerationFromDLMembers="msExchBypassModerationFromDLMembersLink"
[string]$forwardingAddressForcontact="altRecipient"
[string]$grantSendOnBehalfTocontact="publicDelegates"
[array]$contactPropertySet = '*'
[array]$contactPropertySetToClear = @()
[array]$contactPropertiesToClearModern='mapiRecipient','internetEncoding','authOrig','DisplayName','DisplayNamePrintable',$rejectMessagesFromContactMembers,$acceptMessagesFromContactMembers,'extensionAttribute1','extensionAttribute10','extensionAttribute11','extensionAttribute12','extensionAttribute13','extensionAttribute14','extensionAttribute15','extensionAttribute2','extensionAttribute3','extensionAttribute4','extensionAttribute5','extensionAttribute6','extensionAttribute7','extensionAttribute8','extensionAttribute9','legacyExchangeDN','mail','mailNickName','msExchRecipientDisplayType','msExchRecipientTypeDetails','msExchRemoteRecipientType',$bypassModerationFromContact,$bypassModerationFromDLMembers,'msExchBypassModerationLink','msExchCoManagedByLink','msExchEnableModeration','msExchExtensionCustomAttribute1','msExchExtensionCustomAttribute2','msExchExtensionCustomAttribute3','msExchExtensionCustomAttribute4','msExchExtensionCustomAttribute5','msExchGroupDepartRestriction','msExchGroupJoinRestriction','msExchHideFromAddressLists','msExchModeratedByLink','msExchModerationFlags','msExchRequireAuthToSendTo','msExchSenderHintTranslations','oofReplyToOriginator','proxyAddresses',$grantSendOnBehalfToContact,'reportToOriginator','reportToOwner','unAuthOrig','msExchArbitrationMailbox','msExchPoliciesIncluded','msExchUMDtmfMap','msExchVersion','showInAddressBook','msExchAddressBookFlags','msExchBypassAudit','msExchGroupExternalMemberCount','msExchGroupMemberCount','msExchGroupSecurityFlags','msExchLocalizationFlags','msExchMailboxAuditEnable','msExchMailboxAuditLogAgeLimit','msExchMailboxFolderSet','msExchMDBRulesQuota','msExchPoliciesIncluded','msExchProvisioningFlags','msExchRecipientSoftDeletedStatus','msExchRoleGroupType','msExchTransportRecipientSettingsFlags','msExchUMDtmfMap','msExchUserAccountControl','msExchVersion'
[array]$contactPropertiesToClearLegacy='mapiRecipient','internetEncoding','authOrig','DisplayName','DisplayNamePrintable',$rejectMessagesFromContactMembers,$acceptMessagesFromContactMembers,'extensionAttribute1','extensionAttribute10','extensionAttribute11','extensionAttribute12','extensionAttribute13','extensionAttribute14','extensionAttribute15','extensionAttribute2','extensionAttribute3','extensionAttribute4','extensionAttribute5','extensionAttribute6','extensionAttribute7','extensionAttribute8','extensionAttribute9','legacyExchangeDN','mail','mailNickName','msExchRecipientDisplayType','msExchRecipientTypeDetails','msExchRemoteRecipientType',$bypassModerationFromContact,$bypassModerationFromDLMembers,'msExchBypassModerationLink','msExchCoManagedByLink','msExchEnableModeration','msExchExtensionCustomAttribute1','msExchExtensionCustomAttribute2','msExchExtensionCustomAttribute3','msExchExtensionCustomAttribute4','msExchExtensionCustomAttribute5','msExchGroupDepartRestriction','msExchGroupJoinRestriction','msExchHideFromAddressLists','msExchModeratedByLink','msExchModerationFlags','msExchRequireAuthToSendTo','msExchSenderHintTranslations','oofReplyToOriginator','proxyAddresses',$grantSendOnBehalfTocontact,'reportToOriginator','reportToOwner','unAuthOrig','msExchArbitrationMailbox','msExchPoliciesIncluded','msExchUMDtmfMap','msExchVersion','showInAddressBook','msExchAddressBookFlags','msExchBypassAudit','msExchGroupExternalMemberCount','msExchGroupMemberCount','msExchLocalizationFlags','msExchMailboxAuditEnable','msExchMailboxAuditLogAgeLimit','msExchMailboxFolderSet','msExchMDBRulesQuota','msExchPoliciesIncluded','msExchProvisioningFlags','msExchRecipientSoftDeletedStatus','msExchRoleGroupType','msExchTransportRecipientSettingsFlags','msExchUMDtmfMap','msExchUserAccountControl','msExchVersion'
#On premises variables for the distribution list to be migrated.
$originalContactConfiguration=$NULL #This holds the on premises contact configuration for the contact to be migrated.
$originalContactConfigurationUpdated=$NULL #This holds the on premises contact configuration post the rename operations.
[array]$exchangecontactMembershipSMTP=@() #Array of contact membership from AD.
[array]$exchangeRejectMessagesSMTP=@() #Array of members with reject permissions from AD.
[array]$exchangeAcceptMessagesSMTP=@() #Array of members with accept permissions from AD.
[array]$exchangeManagedBySMTP=@() #Array of members with manage by rights from AD.
[array]$exchangeModeratedBySMTP=@() #Array of members with moderation rights.
[array]$exchangeBypassModerationSMTP=@() #Array of objects with bypass moderation rights from AD.
[array]$exchangeGrantSendOnBehalfToSMTP=@()
#Define XML files to contain backups.
[string]$originalContactConfigurationADXML = "originalContactConfigurationADXML" #Export XML file of the contact attibutes direct from AD.
[string]$originalContactConfigurationUpdatedXML = "originalContactConfigurationUpdatedXML"
[string]$originalContactConfigurationObjectXML = "originalContactConfigurationObjectXML" #Export of the ad attributes after selecting objects (allows for NULL objects to be presented as NULL)
[string]$office365contactConfigurationXML = "office365contactConfigurationXML"
[string]$office365contactConfigurationPostMigrationXML = "office365contactConfigurationPostMigrationXML"
[string]$office365contactMembershipPostMigrationXML = "office365contactMembershipPostMigrationXML"
[string]$exchangecontactMembershipSMTPXML = "exchangecontactMemberShipSMTPXML"
[string]$exchangeRejectMessagesSMTPXML = "exchangeRejectMessagesSMTPXML"
[string]$exchangeAcceptMessagesSMTPXML = "exchangeAcceptMessagesSMTPXML"
[string]$exchangeManagedBySMTPXML = "exchangeManagedBySMTPXML"
[string]$exchangeModeratedBySMTPXML = "exchangeModeratedBYSMTPXML"
[string]$exchangeBypassModerationSMTPXML = "exchangeBypassModerationSMTPXML"
[string]$exchangeGrantSendOnBehalfToSMTPXML = "exchangeGrantSendOnBehalfToXML"
[string]$allcontactsMemberOfXML = "allcontactsMemberOfXML"
[string]$allcontactsRejectXML = "allcontactsRejectXML"
[string]$allcontactsAcceptXML = "allcontactsAcceptXML"
[string]$allcontactsBypassModerationXML = "allcontactsBypassModerationXML"
[string]$allUsersForwardingAddressXML = "allUsersForwardingAddressXML"
[string]$allcontactsGrantSendOnBehalfToXML = "allcontactsGrantSendOnBehalfToXML"
[string]$allcontactsManagedByXML = "allcontactsManagedByXML"
[string]$allOffice365MemberOfXML="allOffice365MemberOfXML"
[string]$allOffice365AcceptXML="allOffice365AcceptXML"
[string]$allOffice365RejectXML="allOffice365RejectXML"
[string]$allOffice365BypassModerationXML="allOffice365BypassModerationXML"
[string]$allOffice365GrantSendOnBehalfToXML="allOffice365GrantSentOnBehalfToXML"
[string]$allOffice365ManagedByXML="allOffice365ManagedByXML"
[string]$allOffice365ForwardingAddressXML="allOffice365ForwardingAddressXML"
[string]$allcontactsCoManagedByXML="allcontactsCoManagedByXML"
#The following variables hold information regarding other contacts in the environment that have dependnecies on the contact to be migrated.
[array]$allcontactsMemberOf=$NULL #Complete AD information for all contacts the migrated contact is a member of.
[array]$allcontactsReject=$NULL #Complete AD inforomation for all contacts that the migrated contact has reject mesages from.
[array]$allcontactsAccept=$NULL #Complete AD information for all contacts that the migrated contact has accept messages from.
[array]$allcontactsBypassModeration=$NULL #Complete AD information for all contacts that the migrated contact has bypass moderations.
[array]$allUsersForwardingAddress=$NULL #All users on premsies that have this contact as a forwarding DN.
[array]$allcontactsGrantSendOnBehalfTo=$NULL #All dependencies on premsies that have grant send on behalf to.
[array]$allcontactsManagedBy=$NULL
[array]$allcontactsCoManagedByBL=$NULL
#The following variables hold information regarding Office 365 objects that have dependencies on the migrated contact.
#The following are for standard distribution contacts.
[array]$allOffice365MemberOf=$NULL
[array]$allOffice365Accept=$NULL
[array]$allOffice365Reject=$NULL
[array]$allOffice365BypassModeration=$NULL
[array]$allOffice365ManagedBy=$NULL
#These are for other mail enabled objects.
[array]$allOffice365ForwardingAddress=$NULL
#The following are the cloud parameters we query for to look for dependencies.
[string]$office365AcceptMessagesFrom="AcceptMessagesOnlyFrom"
[string]$office365BypassModerationFrom="BypassModerationFrom"
[string]$office365ManagedBy="ManagedBy"
[string]$office365GrantSendOnBehalfTo="GrantSendOnBehalfTo"
[string]$office365Members="Members"
[string]$office365RejectMessagesFrom="RejectMessagesFrom"
[string]$office365ForwardingAddress="ForwardingAddress"
[string]$office365BypassModerationusers="BypassModerationFromSendersOrMembers"
[string]$office365UnifiedAccept="AcceptMessagesOnlyFromSendersOrMembers"
[string]$office365UnifiedReject="RejectMessagesFromSendersOrMembers"
#The following are the on premises parameters utilized for restoring depdencies.
[string]$onPremUnAuthOrig="unauthorig"
[string]$onPremAuthOrig="authOrig"
[string]$onPremManagedBy="managedBy"
[string]$onPremMSExchCoManagedByLink="msExchCoManagedByLink"
[string]$onPremPublicDelegate="publicDelegates"
[string]$onPremMsExchModeratedByLink="msExchModeratedByLink"
[string]$onPremmsExchBypassModerationLink="msExchBypassModerationLink"
[string]$onPremMemberOf="member"
[string]$onPremAltRecipient="altRecipient"
#Cloud variables for the distribution list to be migrated.
$office365contactConfiguration = $NULL #This holds the office 365 contact configuration for the contact to be migrated.
$office365contactConfigurationPostMigration = $NULL
#Declare some variables for string processing as items move around.
[string]$tempOU=$NULL
[array]$tempNameArrayArray=@()
[string]$tempName=$NULL
[string]$tempDN=$NULL
#For loop counter.
[int]$forLoopCounter=0
#Exchange Schema Version
[int]$exchangeRangeUpper=$NULL
[int]$exchangeLegacySchemaVersion=15317 #Exchange 2016 Preview Schema - anything less is legacy.
#Define new arrays to check for errors instead of failing.
[array]$preCreateErrors=@()
[array]$global:postCreateErrors=@()
[array]$onPremReplaceErrors=@()
[array]$office365ReplaceErrors=@()
[array]$global:office365ReplacePermissionsErrors=@()
[array]$global:onPremReplacePermissionsErrors=@()
[array]$generalErrors=@()
[string]$isTestError="No"
#Define variables specific to contact migration.
$normalizedManager=$NULL
[int]$forLoopTrigger=1000
#Define the sub folders for multi-threading.
[array]$threadFolder="\Thread0","\Thread1","\Thread2","\Thread3","\Thread4","\Thread5","\Thread6","\Thread7","\Thread8","\Thread9","\Thread10"
#Define the status directory.
[string]$global:statusPath="\Status\"
[string]$global:fullStatusPath=$NULL
[int]$statusFileCount=0
#To support the new feature for multiple onmicrosoft.com domains -> use this variable to hold the cross premsies routing domain.
#This value can no longer be calculated off the [email protected] value.
[string]$mailOnMicrosoftComDomain = ""
#If multi threaded - the log directory needs to be created for each thread.
#Create the log folder path for status before changing the log folder path.
if ($totalThreadCount -gt 0)
{
new-statusFile -logFolderPath $logFolderPath
$logFolderPath=$logFolderPath+$threadFolder[$global:threadNumber]
}
#Ensure that no status files exist at the start of the run.
if ($totalThreadCount -gt 0)
{
if ($global:threadNumber -eq 1)
{
remove-statusFiles -fullCleanup:$TRUE
}
}
#Log start of contact migration to the log file.
new-LogFile -contactSMTPAddress $contactSMTPAddress.trim() -logFolderPath $logFolderPath
Out-LogFile -string "================================================================================"
Out-LogFile -string "BEGIN START-CONTACTMIGRATION"
Out-LogFile -string "================================================================================"
out-logfile -string "Set error action preference to continue to allow write-error in out-logfile to service exception retrys"
if ($errorActionPreference -ne "Continue")
{
out-logfile -string ("Current Error Action Preference: "+$errorActionPreference)
$errorActionPreference = "Continue"
out-logfile -string ("New Error Action Preference: "+$errorActionPreference)
}
else
{
out-logfile -string ("Current Error Action Preference is CONTINUE: "+$errorActionPreference)
}
out-logfile -string "Ensure that all strings specified have no leading or trailing spaces."
#Perform cleanup of any strings so that no spaces existin trailing or leading.
$contactSMTPAddress = remove-stringSpace -stringToFix $contactSMTPAddress
$globalCatalogServer = remove-stringSpace -stringToFix $globalCatalogServer
$logFolderPath = remove-stringSpace -stringToFix $logFolderPath
if ($aadConnectServer -ne $NULL)
{
$aadConnectServer = remove-stringSpace -stringToFix $aadConnectServer
}
if ($exchangeOnlineCertificateThumbPrint -ne "")
{
$exchangeOnlineCertificateThumbPrint=remove-stringSpace -stringToFix $exchangeOnlineCertificateThumbPrint
}
$exchangeOnlineEnvironmentName=remove-stringSpace -stringToFix $exchangeOnlineEnvironmentName
if ($exchangeOnlineOrganizationName -ne "")
{
$exchangeOnlineOrganizationName=remove-stringSpace -stringToFix $exchangeOnlineOrganizationName
}
if ($exchangeOnlineAppID -ne "")
{
$exchangeOnlineAppID=remove-stringSpace -stringToFix $exchangeOnlineAppID
}
$dnNoSyncOU = remove-StringSpace -stringToFix $dnNoSyncOU
#Output parameters to the log file for recording.
#For parameters that are optional if statements determine if they are populated for recording.
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "PARAMETERS"
Out-LogFile -string "********************************************************************************"
Out-LogFile -string ("contactSMTPAddress = "+$contactSMTPAddress)
out-logfile -string ("contact SMTP Address Length = "+$contactSMTPAddress.length.tostring())
out-logfile -string ("Spaces Removed contact SMTP Address: "+$contactSMTPAddress)
out-logfile -string ("contact SMTP Address Length = "+$contactSMTPAddress.length.toString())
Out-LogFile -string ("GlobalCatalogServer = "+$globalCatalogServer)
Out-LogFile -string ("ActiveDirectoryUserName = "+$activeDirectoryCredential.UserName.tostring())
Out-LogFile -string ("LogFolderPath = "+$logFolderPath)
if ($aadConnectServer -ne "")
{
$aadConnectServer = $aadConnectServer -replace '\s',''
Out-LogFile -string ("AADConnectServer = "+$aadConnectServer)
}
if ($aadConnectCredential -ne $null)
{
Out-LogFile -string ("AADConnectUserName = "+$aadConnectCredential.UserName.tostring())
}
if ($exchangeOnlineCredential -ne $null)
{
Out-LogFile -string ("ExchangeOnlineUserName = "+ $exchangeOnlineCredential.UserName.toString())
}
if ($exchangeOnlineCertificateThumbPrint -ne "")
{
Out-LogFile -string ("ExchangeOnlineCertificateThumbprint = "+$exchangeOnlineCertificateThumbPrint)
}
out-logfile -string ("OU that does not sync to Office 365 = "+$dnNoSyncOU)
out-logfile -string ("Will the original contact be retained as part of migration = "+$retainOriginalContact)
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "********************************************************************************"
Out-LogFile -string " RECORD VARIABLES"
Out-LogFile -string "********************************************************************************"
out-logfile -string ("Global Catalog Port = "+$globalCatalogPort)
out-logfile -string ("Global catalog string used for function queries ="+$globalCatalogWithPort)
Out-LogFile -string ("Initial user of ADConnect = "+$useAADConnect)
Out-LogFile -string ("AADConnect powershell session name = "+$aadConnectPowershellSessionName)
Out-LogFile -string ("AD Global catalog powershell session name = "+$ADGlobalCatalogPowershellSessionName)
Out-LogFile -string ("Exchange powershell module name = "+$exchangeOnlinePowershellModuleName)
Out-LogFile -string ("Active directory powershell modulename = "+$activeDirectoryPowershellModuleName)
out-logFile -string ("Static property for accept messages from members = "+$acceptMessagesFromcontactMembers)
out-logFile -string ("Static property for accept messages from members = "+$rejectMessagesFromcontactMembers)
Out-LogFile -string ("contact Properties to collect = ")
foreach ($contactProperty in $contactPropertySet)
{
Out-LogFile -string $contactProperty
}
Out-LogFile -string ("contact property set to be cleared legacy = ")
foreach ($contactProperty in $contactPropertiesToClearLegacy)
{
Out-LogFile -string $contactProperty
}
Out-LogFile -string ("contact property set to be cleared modern = ")
foreach ($contactProperty in $contactPropertiesToClearModern)
{
Out-LogFile -string $contactProperty
}
Out-LogFile -string ("Exchange on prem contact active directory configuration XML = "+$originalContactConfigurationADXML)
Out-LogFile -string ("Exchange on prem contact object configuration XML = "+$originalContactConfigurationObjectXML)
Out-LogFile -string ("Office 365 contact configuration XML = "+$office365contactConfigurationXML)
Out-LogFile -string ("Exchange contact members XML Name - "+$exchangecontactMembershipSMTPXML)
Out-LogFile -string ("Exchange Reject members XML Name - "+$exchangeRejectMessagesSMTPXML)
Out-LogFile -string ("Exchange Accept members XML Name - "+$exchangeAcceptMessagesSMTPXML)
Out-LogFile -string ("Exchange ManagedBY members XML Name - "+$exchangeManagedBySMTPXML)
Out-LogFile -string ("Exchange ModeratedBY members XML Name - "+$exchangeModeratedBySMTPXML)
Out-LogFile -string ("Exchange BypassModeration members XML Name - "+$exchangeBypassModerationSMTPXML)
out-logfile -string ("Exchange GrantSendOnBehalfTo members XML name - "+$exchangeGrantSendOnBehalfToSMTPXML)
Out-LogFile -string ("All contact members XML Name - "+$allcontactsMemberOfXML)
Out-LogFile -string ("All Reject members XML Name - "+$allcontactsRejectXML)
Out-LogFile -string ("All Accept members XML Name - "+$allcontactsAcceptXML)
Out-Logfile -string ("All Co Managed By BL XML - "+$allcontactsCoManagedByXML)
Out-LogFile -string ("All BypassModeration members XML Name - "+$allcontactsBypassModerationXML)
out-logfile -string ("All Users Forwarding Address members XML Name - "+$allUsersForwardingAddressXML)
out-logfile -string ("All contacts Grand Send On Behalf To XML Name - "+$allcontactsGrantSendOnBehalfToXML)
out-logfile -string ("Property in office 365 for accept members = "+$office365AcceptMessagesFrom)
out-logfile -string ("Property in office 365 for bypassmoderation members = "+$office365BypassModerationFrom)
out-logfile -string ("Property in office 365 for coManagers members = "+$office365CoManagers)
out-logfile -string ("Property in office 365 for coManagers members = "+$office365GrantSendOnBehalfTo)
out-logfile -string ("Property in office 365 for grant send on behalf to members = "+$office365GrantSendOnBehalfTo)
out-logfile -string ("Property in office 365 for managed by members = "+$office365ManagedBy)
out-logfile -string ("Property in office 365 for members = "+$office365Members)
out-logfile -string ("Property in office 365 for reject messages from members = "+$office365RejectMessagesFrom)
Out-LogFile -string "********************************************************************************"
#Perform paramter validation manually.
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "ENTERING PARAMTER VALIDATION"
Out-LogFile -string "********************************************************************************"
#Test to ensure that if any of the aadConnect parameters are passed - they are passed together.
Out-LogFile -string "Validating that both AADConnectServer and AADConnectCredential are specified"
if (($aadConnectServer -eq "") -and ($aadConnectCredential -ne $null))
{
#The credential was specified but the server name was not.
Out-LogFile -string "ERROR: AAD Connect Server is required when specfying AAD Connect Credential" -isError:$TRUE
}
elseif (($aadConnectCredential -eq $NULL) -and ($aadConnectServer -ne ""))
{
#The server name was specified but the credential was not.
Out-LogFile -string "ERROR: AAD Connect Credential is required when specfying AAD Connect Server" -isError:$TRUE
}
elseif (($aadConnectCredential -ne $NULL) -and ($aadConnectServer -ne ""))
{
#The server name and credential were specified for AADConnect.
Out-LogFile -string "AADConnectServer and AADConnectCredential were both specified."
#Set useAADConnect to TRUE since the parameters necessary for use were passed.
$useAADConnect=$TRUE
Out-LogFile -string ("Set useAADConnect to TRUE since the parameters necessary for use were passed. - "+$useAADConnect)
}
else
{
Out-LogFile -string ("Neither AADConnect Server or AADConnect Credentials specified - retain useAADConnect FALSE - "+$useAADConnect)
}
#Validate that only one method of engaging exchange online was specified.
Out-LogFile -string "Validating Exchange Online Credentials."
if (($exchangeOnlineCredential -ne $NULL) -and ($exchangeOnlineCertificateThumbPrint -ne ""))
{
Out-LogFile -string "ERROR: Only one method of cloud authentication can be specified. Use either cloud credentials or cloud certificate thumbprint." -isError:$TRUE
}
elseif (($exchangeOnlineCredential -eq $NULL) -and ($exchangeOnlineCertificateThumbPrint -eq ""))
{
out-logfile -string "ERROR: One permissions method to connect to Exchange Online must be specified." -isError:$TRUE
}
else
{
Out-LogFile -string "Only one method of Exchange Online authentication specified."
}
#Validate that all information for the certificate connection has been provieed.
if (($exchangeOnlineCertificateThumbPrint -ne "") -and ($exchangeOnlineOrganizationName -eq "") -and ($exchangeOnlineAppID -eq ""))
{
out-logfile -string "The exchange organiztion name and application ID are required when using certificate thumbprint authentication to Exchange Online." -isError:$TRUE
}
elseif (($exchangeOnlineCertificateThumbPrint -ne "") -and ($exchangeOnlineOrganizationName -ne "") -and ($exchangeOnlineAppID -eq ""))
{
out-logfile -string "The exchange application ID is required when using certificate thumbprint authentication." -isError:$TRUE
}
elseif (($exchangeOnlineCertificateThumbPrint -ne "") -and ($exchangeOnlineOrganizationName -eq "") -and ($exchangeOnlineAppID -ne ""))
{
out-logfile -string "The exchange organization name is required when using certificate thumbprint authentication." -isError:$TRUE
}
else
{
out-logfile -string "All components necessary for Exchange certificate thumbprint authentication were specified."
}
#exit #Debug exit.
#Validate that an OU was specified <if> retain contact is not set to true.
Out-LogFile -string "Validating that if retain original contact is false a non-sync OU is specified."
if (($retainOriginalContact -eq $FALSE) -and ($dnNoSyncOU -eq "NotSet"))
{
out-LogFile -string "A no SYNC OU is required if retain original contact is false." -isError:$TRUE
}
Out-LogFile -string "END PARAMETER VALIDATION"
Out-LogFile -string "********************************************************************************"
Out-Logfile -string "Determine Exchange Schema Version"
try{
$exchangeRangeUpper = get-ExchangeSchemaVersion -globalCatalogServer $globalCatalogServer -adCredential $activeDirectoryCredential -errorAction STOP
out-logfile -string ("The range upper for Exchange Schema is: "+ $exchangeRangeUpper)
}
catch{
out-logfile -string "Error occured obtaining the Exchange Schema Version."
out-logfile -string $_ -isError:$TRUE
}
if ($exchangeRangeUpper -ge $exchangeLegacySchemaVersion)
{
out-logfile -string "Modern exchange version detected - using modern parameters"
$contactPropertySetToClear=$contactPropertiesToClearModern
}
else
{
out-logfile -string "Legacy exchange versions detected - using legacy parameters"
$contactPropertySetToClear = $contactPropertiesToClearLegacy
}
Out-LogFile -string ("contact property set to be cleared after schema evaluation = ")
foreach ($contactProperty in $contactPropertySetToClear)
{
Out-LogFile -string $contactProperty
}
# EXIT #Debug Exit
#If exchange server information specified - create the on premises powershell session.
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "ESTABLISH POWERSHELL SESSIONS"
Out-LogFile -string "********************************************************************************"
#Test to determine if the exchange online powershell module is installed.
#The exchange online session has to be established first or the commancontactet set from on premises fails.
Out-LogFile -string "Calling Test-PowerShellModule to validate the Exchange Module is installed."
Test-PowershellModule -powershellModuleName $exchangeOnlinePowershellModuleName -powershellVersionTest:$TRUE
Out-LogFile -string "Calling Test-PowerShellModule to validate the Active Directory is installed."
Test-PowershellModule -powershellModuleName $activeDirectoryPowershellModuleName
out-logfile -string "Calling Test-PowershellModule to validate the contact Conversion Module version installed."
Test-PowershellModule -powershellModuleName $contactConversionPowershellModule -powershellVersionTest:$TRUE
#Create the connection to exchange online.
Out-LogFile -string "Calling New-ExchangeOnlinePowershellSession to create session to office 365."
if ($exchangeOnlineCredential -ne $NULL)
{
#User specified non-certifate authentication credentials.
try {
New-ExchangeOnlinePowershellSession -exchangeOnlineCredentials $exchangeOnlineCredential -exchangeOnlineEnvironmentName $exchangeOnlineEnvironmentName -debugLogPath $logFolderPath
}
catch {
out-logfile -string "Unable to create the exchange online connection using credentials."
out-logfile -string $_ -isError:$TRUE
}
}
elseif ($exchangeOnlineCertificateThumbPrint -ne "")
{
#User specified thumbprint authentication.
try {
new-ExchangeOnlinePowershellSession -exchangeOnlineCertificateThumbPrint $exchangeOnlineCertificateThumbPrint -exchangeOnlineAppId $exchangeOnlineAppID -exchangeOnlineOrganizationName $exchangeOnlineOrganizationName -exchangeOnlineEnvironmentName $exchangeOnlineEnvironmentName -debugLogPath $logFolderPath
}
catch {
out-logfile -string "Unable to create the exchange online connection using certificate."
out-logfile -string $_ -isError:$TRUE
}
}
#exit #debug exit
#If the administrator has specified aad connect information - establish the powershell session.
Out-LogFile -string "Determine if AAD Connect information specified and establish session if necessary."
if ($useAADConnect -eq $TRUE)
{
try
{
out-logfile -string "Creating powershell session to the AD Connect server."
New-PowershellSession -Server $aadConnectServer -Credentials $aadConnectCredential -PowershellSessionName $aadConnectPowershellSessionName
}
catch
{
out-logfile -string "Unable to create remote powershell session to the AD Connect server."
out-logfile -string $_ -isError:$TRUE
}
}
#Establish powershell session to the global catalog server.
try
{
Out-LogFile -string "Establish powershell session to the global catalog server specified."
new-powershellsession -server $globalCatalogServer -credentials $activeDirectoryCredential -powershellsessionname $ADGlobalCatalogPowershellSessionName
}
catch
{
out-logfile -string "Unable to create remote powershell session to the AD Global Catalog server."
out-logfile -string $_ -isError:$TRUE
}
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "END ESTABLISH POWERSHELL SESSIONS"
Out-LogFile -string "********************************************************************************"
#EXIT #Debug Exit
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "BEGIN GET ORIGINAL contact CONFIGURATION LOCAL AND CLOUD"
Out-LogFile -string "********************************************************************************"
#At this point we are ready to capture the original contact configuration. We'll use the ad provider to gather this information.
Out-LogFile -string "Getting the original contact Configuration"
try
{
$originalContactConfiguration = Get-ADObjectConfiguration -contactSMTPAddress $contactSMTPAddress -globalCatalogServer $globalCatalogWithPort -parameterSet $contactPropertySet -errorAction STOP -adCredential $activeDirectoryCredential
}
catch
{
out-logfile -string $_ -isError:$TRUE
}
Out-LogFile -string "Log original contact configuration."
out-logFile -string $originalContactConfiguration
Out-LogFile -string "Create an XML file backup of the on premises contact Configuration"
Out-XMLFile -itemToExport $originalContactConfiguration -itemNameToExport $originalContactConfigurationADXML
#exit #Debug Exit
Out-LogFile -string "Capture the original office 365 distribution list information."
if ($allowNonSyncedcontact -eq $FALSE)
{
try
{
$office365contactConfiguration=Get-O365contactConfiguration -contactSMTPAddress $contactSMTPAddress -errorAction STOP
}
catch
{
out-logFile -string $_ -isError:$TRUE
}
}
else
{
$office365contactConfiguration="DistributionListIsNonSynced"
}
Out-LogFile -string $office365contactConfiguration
Out-LogFile -string "Create an XML file backup of the office 365 contact configuration."
Out-XMLFile -itemToExport $office365contactConfiguration -itemNameToExport $office365contactConfigurationXML
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "END GET ORIGINAL contact CONFIGURATION LOCAL AND CLOUD"
Out-LogFile -string "********************************************************************************"
if ($allowNonSyncedcontact -eq $FALSE)
{
Out-LogFile -string "Perform a safety check to ensure that the distribution list is directory sync."
try
{
Invoke-Office365SafetyCheck -o365contactconfiguration $office365contactConfiguration -errorAction STOP
}
catch
{
out-logFile -string $_ -isError:$TRUE
}
}
else
{
out-logfile -string "The administrator is attempting to migrate a non-synced contact. Office 365 check skipped."
try
{
test-nonSynccontact -originalContactConfiguration $originalContactConfiguration -errorAction STOP
}
catch
{
out-logfile -string $_ -isError:$TRUE
}
}
#At this time we have the contact configuration on both sides and have checked to ensure it is dir synced.
#Membership of attributes is via DN - these need to be normalized to SMTP addresses in order to find users in Office 365.
#Start with contact membership and normallize.
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "BEGIN NORMALIZE DNS FOR ALL ATTRIBUTES"
Out-LogFile -string "********************************************************************************"
out-logfile -string "Invoke get-normalizedDN to normalize the manager."
if ($originalContactConfiguration.manager -ne $NULL)
{
$isTestError="No"
try
{
$normalizedTest = get-normalizedDN -globalCatalogServer $globalCatalogWithPort -DN $originalContactConfiguration.manager -adCredential $activeDirectoryCredential -originalcontactDN $originalContactConfiguration.distinguishedName -isMember:$FALSE -errorAction STOP -cn "None"
if ($normalizedTest.isError -eq $TRUE)
{
$isErrorObject = new-Object psObject -property @{
primarySMTPAddressOrUPN = $normalizedTest.name
externalDirectoryObjectID = $NULL
alias=$normalizedTest.alias
name=$normalizedTest.name
attribute = "Mail contact manager error."
errorMessage = $normalizedTest.isErrorMessage
}
out-logfile -string $isErrorObject
$preCreateErrors+=$isErrorObject
$normalizedManager="None"
}
else
{
$normalizedManager=$normalizedTest
}
}
catch
{
out-logfile -string $_ -isError:$TRUE
}
}
else
{
$normalizedManager="None"
}
Out-LogFile -string "Invoke get-NormalizedDN to normalize the members DN to Office 365 identifier."
if ($originalContactConfiguration.member -ne $NULL)
{
foreach ($DN in $originalContactConfiguration.member)
{
#Resetting error variable.
$isTestError="No"
if ($forLoopCounter -eq $forLoopTrigger)
{
start-sleepProgress -sleepString "Throttling for 5 seconds..." -sleepSeconds 5
$forLoopCounter = 0
}
else
{
$forLoopCounter++
}
try
{
$normalizedTest = get-normalizedDN -globalCatalogServer $globalCatalogWithPort -DN $DN -adCredential $activeDirectoryCredential -originalcontactDN $originalContactConfiguration.distinguishedName -isMember:$TRUE -errorAction STOP -cn "None"
if ($normalizedTest.isError -eq $TRUE)
{
$isErrorObject = new-Object psObject -property @{
primarySMTPAddressOrUPN = $normalizedTest.name
externalDirectoryObjectID = $NULL
alias=$normalizedTest.alias
name=$normalizedTest.name
attribute = "Distribution List Membership (ADAttribute: Members)"
errorMessage = $normalizedTest.isErrorMessage
}
out-logfile -string $isErrorObject
$preCreateErrors+=$isErrorObject
}
else
{
$exchangecontactMembershipSMTP+=$normalizedTest
}
}
catch
{
out-logfile -string $_ -isError:$TRUE
}
}
}
if ($exchangecontactMembershipSMTP -ne $NULL)
{
Out-LogFile -string "The following objects are members of the contact:"
out-logfile -string $exchangecontactMembershipSMTP
}
else
{
out-logFile -string "The distribution contact has no members."
}
Out-LogFile -string "Invoke get-NormalizedDN to normalize the reject members DN to Office 365 identifier."
Out-LogFile -string "REJECT USERS"
if ($originalContactConfiguration.unAuthOrig -ne $NULL)
{
foreach ($DN in $originalContactConfiguration.unAuthOrig)
{
if ($forLoopCounter -eq $forLoopTrigger)
{
start-sleepProgress -sleepString "Throttling for 5 seconds..." -sleepSeconds 5
$forLoopCounter = 0
}
else
{
$forLoopCounter++
}
try
{
$normalizedTest = get-normalizedDN -globalCatalogServer $globalCatalogWithPort -DN $DN -adCredential $activeDirectoryCredential -originalcontactDN $originalContactConfiguration.distinguishedName -errorAction STOP -cn "None"
if ($normalizedTest.isError -eq $TRUE)
{
$isErrorObject = new-Object psObject -property @{
primarySMTPAddressOrUPN = $normalizedTest.name
externalDirectoryObjectID = $NULL
alias=$normalizedTest.alias
name=$normalizedTest.name
attribute = "RejectMessagesFrom (ADAttribute: UnAuthOrig)"
errorMessage = $normalizedTest.isErrorMessage
errorMessageDetail = ""
}
out-logfile -string $isErrorObject
$preCreateErrors+=$isErrorObject
}
else
{
$exchangeRejectMessagesSMTP+=$normalizedTest
}
}
catch
{
out-logfile -string $_ -isError:$TRUE
}