start-testO365UnifiedGroupDependency.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
    Function start-testO365UnifiedGroupDependency
    {
        <#
    .SYNOPSIS
 
    This function tests pre-requists for migrating directly to a Office 365 Unified Group.
 
    .DESCRIPTION
 
    This function tests pre-requists for migrating directly to a Office 365 Unified Group.
 
    .PARAMETER exchangeDLMembership
 
    The members of the distribution group.
 
    .PARAMETER exchangeBypassModerationSMTP
 
    All users with bypass moderation rights that cannot be mirrored in the service.
 
    .PARAMETER allObjectsSendAsNormalized
 
    All objects with send as rights that cannot be mirrored in the service.
 
    .PARAMETER allOffice365ManagedBy
 
    All groups that have the list as a manager.
 
    .PARAMETER allOffice365SendAsAccess
 
    All groups in Office 365 that this group has send as rights on.
 
    .PARAMETER allOffice365FullMailboxAccess
 
    All objects in Office 365 the migrated group has full mailbox access on.
 
    .PARAMETER allOffice365MailboxFolderPermissions
 
    All objects in Office 365 the migrated group has mailbox folder permissions on.
 
    .PARAMETER addManagersAsMembers
 
    Specifies if managers will be added as members - since owners must be members of a unified group.
 
    .OUTPUTS
 
    None
 
    .EXAMPLE
 
    sstart-replaceOffice365 -office365Attribute Attribute -office365Member groupMember -groupSMTPAddress smtpAddess
 
    #>

    
        [cmdletbinding()]

        Param
        (
            [Parameter(Mandatory = $true , ParameterSetName = 'FirstPass')]
            [AllowNull()]
            $exchangeDLMembershipSMTP,
            [Parameter(Mandatory = $true , ParameterSetName = 'FirstPass')]
            [AllowNull()]
            $exchangeBypassModerationSMTP,
            [Parameter(Mandatory = $true , ParameterSetName = 'FirstPass')]
            [AllowNull()]
            $exchangeManagedBySMTP,
            [Parameter(Mandatory = $true , ParameterSetName = 'FirstPass')]
            [AllowNull()]
            $allObjectsSendAsAccessNormalized,
            [Parameter(Mandatory = $true , ParameterSetName = 'SecondPass')]
            [AllowNull()]
            $allOffice365ManagedBy,
            [Parameter(Mandatory = $true , ParameterSetName = 'SecondPass')]
            [AllowNull()]
            $allOffice365SendAsAccess,
            [Parameter(Mandatory = $true , ParameterSetName = 'SecondPass')]
            [AllowNull()]
            $allOffice365FullMailboxAccess,
            [Parameter(Mandatory = $true , ParameterSetName = 'SecondPass')]
            [AllowNull()]
            $allOffice365MailboxFolderPermissions,
            [Parameter(Mandatory = $true , ParameterSetName = 'FirstPass')]
            [AllowNull()]
            [boolean]$addManagersAsMembers,
            [Parameter(Mandatory = $true , ParameterSetName = 'FirstPass')]
            [AllowNull()]
            $originalDLConfiguration,
            [Parameter(Mandatory = $true , ParameterSetName = 'FirstPass')]
            [AllowNull()]
            $overrideSecurityGroupCheck
        )

        write-functionParameters -keyArray $MyInvocation.MyCommand.Parameters.Keys -parameterArray $PSBoundParameters -variableArray (Get-Variable -Scope Local -ErrorAction Ignore)

        $functionObjectClassContact = "Contact"
        $functionObjectClassGroup = "Group"
        $functionObjectClassDynamic = "msExchDynamicDistributionList"
        $functionCoManagers = "msExchCoManagedByLink"
        $functionManagers = "managedBy"
        $functionFirstPassParameterSetName = "FirstPass"
        $functionRoomRecipientTypeDetails = "268435456"

        #Start function processing.

        Out-LogFile -string "********************************************************************************"
        Out-LogFile -string "BEGIN start-testO365UnifiedGroupDependency"
        Out-LogFile -string "********************************************************************************"

        if ($PSCmdlet.ParameterSetName -eq $functionFirstPassParameterSetName)
        {

            Out-logfile -string "Validating security group override."

            if ((($originalDLConfiguration.groupType -eq "-2147483640") -or ($originalDLConfiguration.groupType -eq "-2147483646") -or ($originalDLConfiguration.groupType -eq "-2147483644")) -and ($overrideSecurityGroupCheck -eq $FALSE))
            {
                $errorObject = New-Object PSObject -Property @{
                    Alias = $originalDLConfiguration.mailNickName
                    Name = $originalDLConfiguration.Name
                    PrimarySMTPAddressOrUPN = $originalDLConfiguration.mail
                    GUID = $originalDLConfiguraiton.objectGUID
                    RecipientType = $originalDLConfiguration.objectClass
                    ExchangeRecipientTypeDetails = $originalDLConfiguration.msExchRecipientTypeDetails
                    ExchangeRecipientDisplayType = $originalDLConfiguration.msExchRecipientDisplayType
                    ExchangeRemoteRecipientType = $originalDLConfiguration.msExchRemoteRecipientType
                    GroupType = $originalDLConfiguration.groupType
                    RecipientOrUser = "Recipient"
                    ExternalDirectoryObjectID = $originalDLConfiguration.'msDS-ExternalDirectoryObjectId'
                    OnPremADAttribute = "SecurityGroupCheck"
                    OnPremADAttributeCommonName = "SecurityGroupCheck"
                    DN = $originalDLConfiguration.distinguishedName
                    ParentGroupSMTPAddress = $groupSMTPAddress
                    isAlreadyMigrated = "N/A"
                    isError=$true
                    isErrorMessage="UNIFIED_GROUP_MIGRATION_GROUP_IS_SECURITY_EXCEPTION: To perform an Office 365 Unified Group migration of a mail-enabled security group on premsies the administrator must use -overrideSecurityGroupCheck acknolwedging that permissions may be lost in Office 365 as a result of the migration."
                }

                $global:preCreateErrors+=$errorObject
            }
            else 
            {
                out-logfile -string "Group is not security on premises therefore the administrator does not need to override and acknowledge potentially lost permissions."
            }

            out-logfile -string "Ensuring that the group is not a room distribution list."

            if ($originalDLConfiguration.msExchRecipientTypeDetails -eq $functionRoomRecipientTypeDetails)
            {
                out-logfile -string "Generate error - room distribution list found."

                $functionObject = New-Object PSObject -Property @{
                    Alias = $null
                    Name = $null
                    PrimarySMTPAddressOrUPN = $null
                    GUID = $null
                    RecipientType = $null
                    ExchangeRecipientTypeDetails = $null
                    ExchangeRecipientDisplayType = $null
                    ExchangeRemoteRecipientType = $null
                    GroupType = $NULL
                    RecipientOrUser = $null
                    ExternalDirectoryObjectID = $null
                    OnPremADAttribute = $null
                    OnPremADAttributeCommonName = $null
                    DN = $null
                    ParentGroupSMTPAddress = $null
                    isAlreadyMigrated = $null
                    isError=$True
                    isErrorMessage="UNIFIED_GROUP_MIGRATION_ROOMLIST_EXCEPTION: The distribution list requested for migration to an Office 365 Unified Group is a room distribution list. Room distribution lists cannot be converted to Office 365 Unified Groups."
                }

                $global:preCreateErrors+=$functionObject
            }
            else
            {
                out-logfile -string "Distribution list to be migrated is not a room distribution group."
            }


            out-logfile -string "Test managers for count > 1 which is required for migration."

            if (($exchangeManagedBySMTP -eq $NULL) -or ($exchangeManagedBySMTP.count -eq 0))
            {
                out-logfile -string "A manager attribute is required on premises. Managers is the source of owners for Unified Group."

                $functionObject = New-Object PSObject -Property @{
                    Alias = $null
                    Name = $null
                    PrimarySMTPAddressOrUPN = $null
                    GUID = $null
                    RecipientType = $null
                    ExchangeRecipientTypeDetails = $null
                    ExchangeRecipientDisplayType = $null
                    ExchangeRemoteRecipientType = $null
                    GroupType = $NULL
                    RecipientOrUser = $null
                    ExternalDirectoryObjectID = $null
                    OnPremADAttribute = $null
                    OnPremADAttributeCommonName = "ManagedBy / msExchCoManagedBy"
                    DN = $null
                    ParentGroupSMTPAddress = $null
                    isAlreadyMigrated = $null
                    isError=$True
                    isErrorMessage="UNIFIED_GROUP_MIGRATION_NO_MANAGERS_EXCEPTION: No managers are specified on the on-premsies group. All Office 365 Unified Groups must have at least one owners. Managers are the source of owners in an Office 365 Unified Group Migration."
                }

                $global:preCreateErrors+=$functionObject
            }
            elseif (($exchangeManagedBySMTP -eq $NULL) -or ($exchangeManagedBySMTP.count -gt 100)) 
            {
                out-logfile -string "Manager count is greater than 100 - this migration may not proceed."

                $functionObject = New-Object PSObject -Property @{
                    Alias = $null
                    Name = $null
                    PrimarySMTPAddressOrUPN = $null
                    GUID = $null
                    RecipientType = $null
                    ExchangeRecipientTypeDetails = $null
                    ExchangeRecipientDisplayType = $null
                    ExchangeRemoteRecipientType = $null
                    GroupType = $NULL
                    RecipientOrUser = $null
                    ExternalDirectoryObjectID = $null
                    OnPremADAttribute = $null
                    OnPremADAttributeCommonName = "managedBy / msExchCoManagedBy"
                    DN = $null
                    ParentGroupSMTPAddress = $null
                    isAlreadyMigrated = $null
                    isError=$True
                    isErrorMessage="UNIFIED_GROUP_MIGRATION_TOO_MANY_MANAGERS_EXCEPTION: The managedBy count is greater than 100. An Office 365 Unified Group may not have more than 100 managers."
                }

                $global:preCreateErrors+=$functionObject
            }
            else 
            {
                out-logfile -string "There is at least one manager of the on premises group - proceed with further verification."
            }
        }
        else 
        {
            out-logfile -string "This is not the first pass function call - manager evaluation skipped."
        }

        if ($addManagersAsMembers -eq $FALSE)
        {
            if ($exchangeManagedBySMTP -ne $NULL)
            {
                out-logfile -string "Ensure that each manager is a member prior to proceeding."

                foreach ($member in $exchangeManagedBySMTP)
                {
                    out-logfile -string ("Testing manager in members: "+$member.primarySMTPAddressOrUPN)

                    if ($exchangeDLMembershipSMTP.primarySMTPAddressOrUPN -contains $member.primarySMTPAddressOrUPN)
                    {
                        out-logfile -string "The manager / owner is a member."
                    }
                    else 
                    {
                        out-logfile -string "Manager is not a member of the DL - error."

                        $functionObject = New-Object PSObject -Property @{
                            Alias = $member.alias
                            Name = $member.name
                            PrimarySMTPAddressOrUPN = $member.primarySMTPAddressOrUPN
                            GUID = $member.GUID
                            RecipientType = $member.recipientType
                            ExchangeRecipientTypeDetails = $member.ExchangeRecipientTypeDetails
                            ExchangeRecipientDisplayType = $member.ExchangeRecipientDisplayType
                            ExchangeRemoteRecipientType = $member.exchangeRemoteRecipientType
                            GroupType = $member.groupType
                            RecipientOrUser = $member.recipientOrUser
                            ExternalDirectoryObjectID = $member.externalDirectoryObjectID
                            OnPremADAttribute = $member.OnPremADAttribute
                            OnPremADAttributeCommonName = $member.OnPremADAttributeCommonName
                            DN = $member.dn
                            ParentGroupSMTPAddress = $member.ParentGroupSMTPAddress
                            isAlreadyMigrated = $member.isAlreadyMigrated
                            isError=$true
                            isErrorMessage="UNIFIED_GROUP_MIGRATION_MANAGER_NOT_MEMBER_EXCEPTION: Office 365 Groups require all owners to be members. ManagedBY is mapped to owners - this manager is not a member of the group. The manage must be removed, use the switch -addManagersAsMembers to add all managers, or manually add this manager as a member."
                        }

                        out-logfile -string $functionObject

                        $global:preCreateErrors+=$functionObject
                    }
                }
            }
            else 
            {
                out-logfile -string "No On Premises Managed By objects were submitted for evaluation this function call."
            }
        }
        else
        {
            out-logfile -string "Adding managers to membership for evalution."

            $exchangeDLMembershipSMTP += $exchangeManagedBySMTP
        }

        if ($exchangeDLMembershipSMTP -ne $NULL)
        {
            out-logfile -string "Evaluating Exchange DL Membership"

            foreach ($member in $exchangeDLMembershipSMTP)
            {
                out-logfile -string ("Testing member: "+$member.name)

                if (($member.recipientType -eq $functionObjectClassContact) -and ($member.isAlreadyMigrated -eq $TRUE))
                {
                    if (($member.OnPremADAttribute -eq $functionCoManagers) -or ($member.OnPremADAttribute -eq $functionManagers))
                    {
                        out-logfile -string "Member is a contact associated with a previously migrated group and is a group manager added to membership - record as error."

                        $member.isError = $true
                        $member.isErrorMessage = "UNIFIED_GROUP_MIGRATION_MIGRATED_CONTACT_MANAGEDBY_EXCEPTION: The contact found is a manager of the group added to members by -addManagersAsMembers. The contact must be removed from managers."  

                        $global:preCreateErrors+=$member
                    }
                    else 
                    {
                        out-logfile -string "Member is a contact associated with a previously migrated group - record as error."

                        $member.isError = $true
                        $member.isErrorMessage = "UNIFIED_GROUP_MIGRATION_MIGRATED_CONTACT_MEMBERSHIP_EXCEPTION: The contact found in this group is from a previously migrated group. This would typically mean this was the parent group that had a child DL that was migrated. Office 365 Groups do not support nested groups. This contact will need to be removed for migration."  

                        $global:preCreateErrors+=$member
                    }
                }
                elseif ($member.recipientType -eq $functionObjectClassContact)
                {
                    if (($member.OnPremADAttribute -eq $functionCoManagers) -or ($member.OnPremADAttribute -eq $functionManagers))
                    {
                        out-logfile -string "Member is a contact added to members with -addManagersAsMembers - record as error"

                        $member.isError = $true
                        $member.isErrorMessage = "UNIFIED_GROUP_MIGRATION_CONTACT_MANAGEDBY_EXCEPTION: The contact found is a manager of the group added to members by -addManagersAsMembers. The contact must be removed from managers."  

                        $global:preCreateErrors+=$member
                    }
                    else
                    {
                        out-logfile -string "Member is a contact - record as error."

                        $member.isError = $true
                        $member.isErrorMessage = "UNIFIED_GROUP_MIGRATION_CONTACT_MEMBERSHIP_EXCEPTION Contacts may not be included in an Office 365 Unified Group. Remove the contact in order to migrate to an Office 365 Unified Group."  

                        $global:preCreateErrors+=$member
                    }
                }
                elseif ($member.recipientType -eq $functionObjectClassGroup)
                {
                    if (($member.OnPremADAttribute -eq $functionCoManagers) -or ($member.OnPremADAttribute -eq $functionManagers))
                    {
                        out-logfile -string "Groups may not be included in an Office 365 Unified Group. Remove the group in order to migrate to an Office 365 Unified Group. Group was added as a member by -addManagersAsMembers."

                        $member.isError = $true
                        $member.isErrorMessage = "UNIFIED_GROUP_MIGRATION_GROUP_MANAGEDBY_EXCEPTION: Groups may not be members of Office 365 Unified Groups. This group was added as a member becuase it is a manager and the migration used -addManagersAsMembers. Remove the group from managers."  

                        $global:preCreateErrors+=$member
                    }
                    else 
                    {
                        out-logfile -string "Member is a group - record as error."

                        $member.isError = $TRUE
                        $member.isErrorMessage = "UNIFIED_GROUP_MIGRATION_GROUP_MEMBERSHIP_EXCEPTION: Groups may not be included in an Office 365 Unified Group. Remove the group in order to migrate to an Office 365 Unified Group"

                        $global:preCreateErrors+=$member
                    }
                }
                elseif ($member.recipientType -eq $functionObjectClassDynamic)
                {
                    out-logfile -string "Member is a dynamic group group - record as error."

                    $member.isError = $TRUE
                    $member.isErrorMessage = "UNIFIED_GROUP_MIGRATION_DYNAMIC_MEMBERSHIP_EXCEPTION: Dyanmic Groups may not be included in an Office 365 Unified Group. Remove the group in order to migrate to an Office 365 Unified Group"

                    $global:preCreateErrors+=$member
                }
                else 
                {
                    out-logfile -string "Member is neither a group nor contact - allow the migrate to proceed."
                }
            }
        }
        else 
        {
            out-logfile -string "No distribution group members were provided on this function call."
        }

        if ($exchangeBypassModerationSMTP -ne $NULL)
        {
            out-logfile -string "Evaluating bypass moderation from senders or members of the on premises group."

            foreach ($member in $exchangeBypassModerationSMTP)
            {
                out-logfile -string ("Testing member: "+$member.name)
                out-logfile -string ("Bypass moderation error - invalid attribute.")

                $member.isError = $TRUE
                $member.isErrorMessage = "UNIFIED_GROUP_MIGRATION_BYPASS_MODERATION_FROM_SENDERS_OR_MEMBERS_EXCEPTION: Office 365 Unified Groups do not have BypassModerationFromSendersOrMembers. To migrate to an Office 365 Unified Group the bypass moderation from senders or members must be cleared."

                $global:preCreateErrors+=$member
            }
        }
        else
        {
            out-logfile -string "No bypass moderation from senders or members supplied in this function call."
        }

        if ($allObjectsSendAsAccessNormalized -ne $NULL)
        {
            out-logfile -string "Evaluating all send as rights discovered on recipient objects on premises.."

            foreach ($member in $allObjectsSendAsAccessNormalized)
            {
                out-logfile -string ("Testing member: "+$member.name)
                out-logfile -string ("Send as error - invalid permission.")

                $member.isError = $TRUE
                $member.isErrorMessage = "UNIFIED_GROUP_MIGRATION_SENDAS_FOUND_EXCEPTION: In order to retain or mirror send as permissiosn the group must be a security group. Office 365 Unified Groups are not securtiy groups. Remove all send as rights for this group on premises to continue converation to an Office 365 Group."

                $global:preCreateErrors+=$member
            }
        }
        else
        {
            out-logfile -string "No on premsies send as rights provided in this function call."
        }

        if ($allOffice365ManagedBy -ne $NULL)
        {
            out-logfile -string "Evaluating all Office 365 Managed By entries..."

            foreach ($member in $allOffice365ManagedBy)
            {
                out-logfile -string ("Testing member: "+$member.name)
                out-logfile -string "ManagedBy error - invalid permission"

                $functionObject = New-Object PSObject -Property @{
                    Alias = $member.alias
                    Name = $member.name
                    PrimarySMTPAddressOrUPN = $member.primarySMTPAddress
                    GUID = $member.GUID
                    RecipientType = $null
                    ExchangeRecipientTypeDetails = $null
                    ExchangeRecipientDisplayType = $null
                    ExchangeRemoteRecipientType = $null
                    GroupType = $NULL
                    RecipientOrUser = $null
                    ExternalDirectoryObjectID = $member.externalDirectoryObjectID
                    OnPremADAttribute = $null
                    OnPremADAttributeCommonName = $null
                    DN = $member.legacyExchangeDN
                    ParentGroupSMTPAddress = $null
                    isAlreadyMigrated = $null
                    isError=$True
                    isErrorMessage="UNIFIED_GROUP_MIGRATION_MANAGEDBY_ON_OTHER_OBJECTS_EXCEPTION: Office 365 Unified Groups are not security enabled. They may not have managed by rights on other groups. Remove the managed by right on this object in Office 365 to proceed with converstion to an Office 365 Unified Group."
                }

                $global:preCreateErrors+=$functionObject
            }
        }
        else 
        {
            out-logfile -string "No Office 365 Managed By objects were submitted for evaluation this function call."
        }

        if ($allOffice365SendAsAccess -ne $NULL)
        {
            out-logfile -string "Evaluating all Office 365 send as acesss"

            foreach ($member in $allOffice365SendAsAccess)
            {
                out-logfile -string ("Testing member: "+$member.Identity)
                out-logfile -string "Send as error - invalid."

                $functionObject = New-Object PSObject -Property @{
                    Alias = $NULL
                    Name = $member.Identity
                    PrimarySMTPAddressOrUPN = $NULL
                    GUID = $NULL
                    RecipientType = $null
                    ExchangeRecipientTypeDetails = $null
                    ExchangeRecipientDisplayType = $null
                    ExchangeRemoteRecipientType = $null
                    GroupType = $NULL
                    RecipientOrUser = $null
                    ExternalDirectoryObjectID = $NULL
                    OnPremADAttribute = $null
                    OnPremADAttributeCommonName = $null
                    DN = $NULL
                    ParentGroupSMTPAddress = $null
                    isAlreadyMigrated = $null
                    isError=$True
                    isErrorMessage="UNIFIED_GROUP_MIGRATION_SENDAS_FOUND_EXCEPTION: An Office 365 Unified Group is not a security principal and may not have send as rights on other objects. Remove the send as rights from these objects to proceed with Office 365 Unified Group conversion."
                }

                $global:preCreateErrors+=$functionObject
            }
        }
        else
        {
            out-logfile -string "No Office 365 Send As permissions were submitted in this function call for evaluation."
        }

        if ($allOffice365FullMailboxAccess -ne $NULL)
        {
            out-logfile -string "Evaluating all Office 365 full mailbox access."

            foreach ($member in $allOffice365FullMailboxAccess)
            {
                out-logfile -string ("Testing member: "+$member.Identity)
                out-logfile -string "Full Mailbox Access Permission Error - invalid permission."

                $functionObject = New-Object PSObject -Property @{
                    Alias = $NULL
                    Name = $member.Identity
                    PrimarySMTPAddressOrUPN = $NULL
                    GUID = $NULL
                    RecipientType = $null
                    ExchangeRecipientTypeDetails = $null
                    ExchangeRecipientDisplayType = $null
                    ExchangeRemoteRecipientType = $null
                    GroupType = $NULL
                    RecipientOrUser = $null
                    ExternalDirectoryObjectID = $NULL
                    OnPremADAttribute = $null
                    OnPremADAttributeCommonName = $null
                    DN = $NULL
                    ParentGroupSMTPAddress = $null
                    isAlreadyMigrated = $null
                    isError=$True
                    isErrorMessage="UNIFIED_GROUP_MIGRATION_FULL_MAILOBOX_ACCESS_EXCEPTION: An Office 365 group is not a security principal. Either remove the full mailbox access rights assigned to the group on this object or do not inclue useCollectedOffice365FullMailboxAccess."
                }

                $global:preCreateErrors+=$functionObject
            }
        }

        if ($allOffice365MailboxFolderPermissions -ne $NULL)
        {
            out-logfile -string "Evaluating all Office 365 send as acesss"

            foreach ($member in $allOffice365MailboxFolderPermissions)
            {
                out-logfile -string ("Testing member: "+$member.Identity)
                out-logfile -string "Mailbox Folder Permission Error - invalid permission."

                $functionObject = New-Object PSObject -Property @{
                    Alias = $member.FolderName
                    Name = $member.Identity
                    PrimarySMTPAddressOrUPN = $NULL
                    GUID = $NULL
                    RecipientType = $null
                    ExchangeRecipientTypeDetails = $null
                    ExchangeRecipientDisplayType = $null
                    ExchangeRemoteRecipientType = $null
                    GroupType = $NULL
                    RecipientOrUser = $null
                    ExternalDirectoryObjectID = $NULL
                    OnPremADAttribute = $null
                    OnPremADAttributeCommonName = $null
                    DN = $NULL
                    ParentGroupSMTPAddress = $null
                    isAlreadyMigrated = $null
                    isError=$True
                    isErrorMessage="UNIFIED_GROUP_MIGRATION_MAILBOX_FOLDER_PERMISSION_EXCEPTION: An Office 365 Unified Group is not a security principal. Remove the folder permissions assigned to the group or do not use the useCollectedOffice365MailboxFolders switch."
                }

                $global:preCreateErrors+=$functionObject
            }
        }
        else 
        {
            out-logfile -string "No Office 365 mailbox folder permissions were submitted for evaluation this function call."
        }

        Out-LogFile -string "END start-testO365UnifiedGroupDependency"
        Out-LogFile -string "********************************************************************************"
    }