-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathGet-O365DLFullMaiboxAccess.ps1
133 lines (95 loc) · 4.49 KB
/
Get-O365DLFullMaiboxAccess.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
<#
.SYNOPSIS
This function searches the collected data for all Office 365 full mailbox access permissions.
.DESCRIPTION
This function searches the collected data for all Office 365 full mailbox access permissions.
.PARAMETER GroupSMTPAddress
The mail attribute of the group to search.
.PARAMETER collectedData
The precollected data utilized for evaluation.
.OUTPUTS
Returns all full mailbox access permissions for the migrated group.
.EXAMPLE
Get-O365DLFullMaiboxAccess -groupSMTPAddress Address -collectedData DataArray
#>
Function Get-O365DLFullMaiboxAccess
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory = $true)]
[string]$groupSMTPAddress,
[Parameter(Mandatory = $false)]
$collectedData=$NULL
)
#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]$functionFullMailboxAccess=@()
$functionMailboxes=$NULL
$functionRecipient=$NULL
#Start function processing.
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "BEGIN Get-O365DLFullMaiboxAccess"
Out-LogFile -string "********************************************************************************"
#Get the recipient using the exchange online powershell session.
if ($collectedData -eq $NULL)
{
<# This is no longer utilized since live collection is not supported. Retaining.
try {
out-logfile -string "Getting recipient..."
#$functionRecipient = get-ExoRecipient -identity $groupSMTPAddress
$functionRecipient = get-o365Recipient -identity $groupSMTPAddress
}
catch {
out-logfile -string $_ -isError:$TRUE
}
#Get all of the mailboxes to test.
try {
out-logfile -string "Getting all Office 365 mailboxes."
#$functionMailboxes = get-exomailbox -resultsize unlimited
$functionMailboxes = get-o365mailbox -resultsize unlimited
}
catch {
out-logfile -string $_ -isError:$TRUE
}
try
{
Out-LogFile -string "Using Exchange Online to locate all of the full mailbox access rights in Office 365."
$ProgressDelta = 100/($functionMailboxes.count); $PercentComplete = 0; $MbxNumber = 0
foreach ($mailbox in $functionMailboxes)
{
$MbxNumber++
write-progress -activity "Processing Recipient" -status $mailbox.primarySMTPAddress -PercentComplete $PercentComplete
$PercentComplete += $ProgressDelta
#$functionFullMailboxAccess+=get-exoMailboxPermission -identity $mailbox.identity | where {$_.user -eq $functionRecipient.identity}
$functionFullMailboxAccess+=get-o365MailboxPermission -identity $mailbox.identity | where {$_.user -eq $functionRecipient.identity}
}
}
catch
{
Out-LogFile -string $_ -isError:$TRUE
}
write-progress -activity "Processing Recipient" -completed
#>
}
elseif ($collectedData -ne $NULL)
{
try {
out-logfile -string "Getting recipient..."
#$functionRecipient = get-ExoRecipient -identity $groupSMTPAddress
$functionRecipient = get-o365Group -identity $groupSMTPAddress
}
catch {
out-logfile -string $_ -isError:$TRUE
}
out-logfile "Obtaining all full mailbox access permissions in Office 365."
$functionFullMailboxAccess = $collectedData | where {$_.usersid -eq $functionRecipient.sid}
}
Out-LogFile -string "END Get-O365DLFullMaiboxAccess"
Out-LogFile -string "********************************************************************************"
if ($functionFullMailboxAccess.count -gt 0)
{
return $functionFullMailboxAccess
}
}