-
Notifications
You must be signed in to change notification settings - Fork 1
/
Add-SympaMailingListMember.ps1
62 lines (51 loc) · 1.97 KB
/
Add-SympaMailingListMember.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
function Add-SympaMailingListMember
{
<#
.Synopsis
This function adds a member(s) to a Mailing list
.EXAMPLE
Add the member [email protected] to the mailing list queens-it
Add-SympaMailingListMember -Sympa $Sympa -MailingList queens-it -Member [email protected]
.EXAMPLE
Add the members [email protected] and [email protected] to the mailing list queens-it
Add-SympaMailingListMember -Sympa $Sympa -MailingList queens-it -Member @('[email protected]','[email protected]')
.EXAMPLE
Get the members from the list queens-test and add them to queens-it
Get-SympaMailingListMember -Sympa $sympa -MailingList queens-test | Add-SympaMailingListMember -Sympa $sympa -MailingList queens-it
#>
param(
[Parameter(Mandatory=$true,HelpMessage="Pass in the result of the 'Get-SympaLogin' function")]
$Sympa,
[Parameter(Mandatory=$true,HelpMessage="Enter the name of the Mailing list you want to add the member(s) to")]
[String]$MailingList,
[Parameter(Mandatory=$true,HelpMessage="Enter the address of the member(s) you want to add to the Mailling list",ValueFromPipelineByPropertyName=$True)]
[Array]$Member
<#
[Parameter(Mandatory=$false,HelpMessage="Should you notify the user that they are being added to the list, default is no")]
[ValidateSet("Yes", "No")]
[String]$Notify = "No"
#>
)
<#
#Handle the $Notify paramater converting it into the mess that Sympa understands
switch ($Notify)
{
'Yes' {$Alert = "false"}
'No' {$Alert = "true"}
Default {$Alert = "true"}
}
#>
Process{
#Loop over the member(s) and add them to the list
foreach($Address in $Member){
try
{
Write-Verbose "Adding $Address to $MailingList"
$Sympa.add("$MailingList","$Address", "","1")
}
catch
{
}
}
}
}