-
Notifications
You must be signed in to change notification settings - Fork 10
/
Get-O365DLSendAs.ps1
101 lines (70 loc) · 3.25 KB
/
Get-O365DLSendAs.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
<#
.SYNOPSIS
This function gathers all Office 365 Send as permissions for the migrated DLs.
.DESCRIPTION
This function gathers all Office 365 Send as permissions for the migrated DLs.
.PARAMETER GroupSMTPAddress
The mail attribute of the group to search.
.PARAMETER isTrustee
Determines if we're searching for permissions on the group itself or permissions for the migrated DL on other objects.
.OUTPUTS
Returns either send as permissions on the migrated DL or all objects that the migrated DL has send as permissions on.
.EXAMPLE
Get-O365DLSendAs -groupSMTPAddress Address -isTrustee:$TRUE
#>
Function Get-O365DLSendAs
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory = $true)]
[string]$groupSMTPAddress,
[Parameter(Mandatory = $false)]
[string]$isTrustee=$FALSE,
[Parameter(Mandatory = $false)]
$office365GroupConfiguration
)
#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.
[array]$functionSendAs=@()
#Start function processing.
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "BEGIN Get-O365DLSendAs"
Out-LogFile -string "********************************************************************************"
#Get the recipient using the exchange online powershell session.
if ($isTrustee -eq $TRUE)
{
try
{
Out-LogFile -string "Obtaining all Office 365 groups the migrated DL has send as permissions on."
$functionSendAs = get-o365RecipientPermission -Trustee $groupSMTPAddress -resultsize unlimited -errorAction STOP
}
catch
{
Out-LogFile -string $_ -isError:$TRUE
}
<#
out-logfile -string "Determining if the group has permissions to itself and excluding it from the array."
out-logfile -string ("PreCount: "+$functionSendAs.Count)
$functionSendAs = $functionSendAs | where {$_.TrusteeSidString -ne $office365GroupConfiguration.SID}
out-logfile -string ("PostCount: "+$functionSendAs.Count)
#>
}
else
{
try
{
out-logfile -string "Obtaining all send as permissions set directly in Office 365 on the group to be migrated."
$functionSendAs = get-O365RecipientPermission -identity $groupSMTPAddress -resultsize unlimited -errorAction STOP
out-logfile -string ("Number of send as located: "+$functionSendAs.Count)
}
catch
{
out-logfile -string $_ -isError:$TRUE
}
}
Out-LogFile -string "END Get-O365DLSendAs"
Out-LogFile -string "********************************************************************************"
return $functionSendAs
}