-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathGet-O365DLMailboxFolderPermissions.ps1
95 lines (63 loc) · 3.25 KB
/
Get-O365DLMailboxFolderPermissions.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
<#
.SYNOPSIS
This function evaluates all Office 365 Mailbox Folder permissions for the migrated distriution groups.
.DESCRIPTION
This function evaluates all Office 365 Mailbox Folder permissions for the migrated distriution groups.
.PARAMETER GroupSMTPAddress
The mail attribute of the group to search.
.PARAMETER collectedData
The precollected data to search for the group.
.OUTPUTS
Returns any mailbox folder permissions for the migrated DL.
.EXAMPLE
Get-O365DLFullMaiboxAccess -groupSMTPAddress Address
#>
Function Get-O365DLMailboxFolderPermissions
{
[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]$functionFolderAccess=@()
#Start function processing.
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "BEGIN Get-O365DLMailboxFolderPermissions"
Out-LogFile -string "********************************************************************************"
#Get the recipient using the exchange online powershell session.
if ($collectedData -eq $NULL)
{
out-logfile -string "No folder permissions were provided for evaluation."
}
elseif ($collectedData -ne $NULL)
{
<#
out-logfile -string "Filter all entries for objects that have been removed."
out-logfile -string ("Pre count: "+$collectedData.count)
$collectedData = $collectedData | where {$_.user.userPrincipalName -ne $NULL}
out-logfile -string ("Post count: "+$collectedData.count)
$functionFolderAccess = $collectedData | where {$_.user.tostring() -eq $groupSMTPAddress}
#>
#Moving back from the EXO function changes the output of the gathered permissions.
#This new code section should address it.
#Retaining the original in case it becomes necessary to revert.
out-logfile -string "Filter all entries for objects that have been removed."
out-logfile -string ("Pre count: "+$collectedData.count)
$collectedData = $collectedData | where {$_.user.RecipientPrincipal.primarySMTPAddress -ne $NULL}
out-logfile -string ("Post count: "+$collectedData.count)
$functionFolderAccess = $collectedData | where {$_.user.RecipientPrincipal.primarySMTPAddress.tostring() -eq $groupSMTPAddress}
}
write-progress -activity "Processing Recipient" -completed
Out-LogFile -string "END Get-O365DLMailboxFolderPermissions"
Out-LogFile -string "********************************************************************************"
if ($functionFolderAccess.count -gt 0)
{
return $functionFolderAccess
}
}