forked from timmcmic/DLConversionV2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-onPremFolderPermissions.ps1
89 lines (64 loc) · 2.85 KB
/
get-onPremFolderPermissions.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
<#
.SYNOPSIS
This function utilizes exchange on premises and searches for all send as rights across all recipients.
.DESCRIPTION
This function utilizes exchange on premises and searches for all send as rights across all recipients.
.PARAMETER originalDLConfiguration
The mail attribute of the group to search.
.OUTPUTS
Returns a list of all objects with send-As rights and exports them.
.EXAMPLE
get-o365dlconfiguration -groupSMTPAddress Address
#>
Function get-onPremFolderPermissions
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory = $true)]
$originalDLConfiguration,
[Parameter(Mandatory=$false)]
$collectedData=$NULL
)
#Declare function variables.
[array]$functionFolderRightsUsers=@()
[int]$functionCounter=0
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "BEGIN get-onPremFolderPermissions"
Out-LogFile -string "********************************************************************************"
try
{
out-logfile -string "Test for folder permissions."
$ProgressDelta = 100/($collectedData.count); $PercentComplete = 0; $MbxNumber = 0
foreach ($recipient in $collectedData)
{
$MbxNumber++
write-progress -activity "Processing Recipient" -status $recipient.identity -PercentComplete $PercentComplete
$PercentComplete += $ProgressDelta
if ($recipient.user.tostring() -notlike "*S-1-5-21*")
{
write-host $recipient.user
write-host $originalDLConfiguration.samAccountName
if ($recipient.user.tostring() -eq $originalDLConfiguration.samAccountName)
{
out-logfile -string ("Mailbox folder permission found - recording."+$recipient.identity)
$functionFolderRightsUsers+=$recipient
}
}
}
}
catch
{
out-logfile -string "Error attempting to invoke command to gather all send as permissions."
out-logfile -string $_ -isError:$TRUE
}
out-logfile -string $functionFolderRightsUsers
write-progress -Activity "Processing Recipient" -Completed
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "END get-onPremFolderPermissions"
Out-LogFile -string "********************************************************************************"
if ($functionFolderRightsUsers.count -gt 0)
{
return $functionFolderRightsUsers
}
}