forked from timmcmic/DLConversionV2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest-AcceptedDomain.ps1
90 lines (65 loc) · 3.12 KB
/
Test-AcceptedDomain.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
<#
.SYNOPSIS
This function tests each accepted domain on the group to ensure it appears in Office 365.
.DESCRIPTION
This function tests each accepted domain on the group to ensure it appears in Office 365.
.EXAMPLE
Test-AcceptedDomain -originalDLConfiguration $originalDLConfiguration
#>
Function Test-AcceptedDomain
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory = $true)]
$originalDLConfiguration
)
#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)
#Define variables that will be utilzed in the function.
[array]$originalDLAddresses=@()
[array]$originalDLDomainNames=@()
#Initiate the test.
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "BEGIN Test-AcceptedDomain"
Out-LogFile -string "********************************************************************************"
foreach ($address in $originalDLConfiguration.proxyAddresses)
{
Out-logfile -string "Testing proxy address for SMTP"
out-logfile -string $address
if ($address -like "smtp*")
{
out-logfile -string ("Address is smtp address: "+$address)
$tempAddress=$address.split("@")
$originalDLDomainNames+=$tempAddress[1]
}
else
{
out-logfile -string ("Address is not an SMTP Address - skip.")
}
}
#It is possible that the group does not have proxy address but just mail - this is now a supported scenario.
#To get this far the object has to have mail.
out-logfile -string ("The mail address is: "+$originalDLConfiguration.mail)
$tempAddress=$originalDLConfiguration.mail.split("@")
$originalDLDomainNames+=$tempAddress[1]
$originalDLDomainNames=$originalDLDomainNames | select-object -Unique
out-logfile -string "Unique domain names on the group."
out-logfile -string $originalDLDomainNames
foreach ($domain in $originalDLDomainNames)
{
out-logfile -string "Testing Office 365 for Domain Name."
if (get-o365acceptedDomain -identity $domain)
{
out-logfile -string ("Domain exists in Office 365. "+$domain)
}
else
{
out-logfile -string $domain
out-logfile -string "Group cannot be migrated until the domain is an accepted domain in Office 365 or removed from the group."
out-logfile -string "Email address exists on group that is not in Office 365." -isError:$TRUE
}
}
Out-LogFile -string "END Test-AcceptedDomain"
Out-LogFile -string "********************************************************************************"
}