forked from timmcmic/DLConversionV2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-O365DLMembership.ps1
68 lines (44 loc) · 1.9 KB
/
Get-O365DLMembership.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
<#
.SYNOPSIS
This function obtains the DL membership of the Office 365 distribution group.
.DESCRIPTION
This function obtains the DL membership of the Office 365 distribution group.
.PARAMETER GroupSMTPAddress
The mail attribute of the group to search.
.OUTPUTS
Returns the membership array of the DL in Office 365.
.EXAMPLE
get-o365dlMembership -groupSMTPAddress Address
#>
Function Get-o365DLMembership
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory = $true)]
[string]$groupSMTPAddress
)
#Declare function variables.
$functionDLMembership=$NULL #Holds the return information for the group query.
#Start function processing.
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "BEGIN GET-O365DLMEMBERSHIP"
Out-LogFile -string "********************************************************************************"
#Log the parameters and variables for the function.
Out-LogFile -string ("GroupSMTPAddress = "+$groupSMTPAddress)
#Get the recipient using the exchange online powershell session.
try
{
Out-LogFile -string "Using Exchange Online to obtain the group membership."
$functionDLMembership=get-O365DistributionGroupMember -identity $groupSMTPAddress -errorAction STOP
Out-LogFile -string "Distribution group membership recorded."
}
catch
{
Out-LogFile -string $_ -isError:$TRUE
}
Out-LogFile -string "END GET-O365DLMEMBERSHIP"
Out-LogFile -string "********************************************************************************"
#Return the membership to the caller.
return $functionDLMembership
}