-
Notifications
You must be signed in to change notification settings - Fork 1
/
Remove-SympaMailingListMember.ps1
63 lines (54 loc) · 2.18 KB
/
Remove-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
63
function Remove-SympaMailingListMember
{
<#
.Synopsis
This function removes a member(s) from a Mailing list
.EXAMPLE
Remove the member jim.bob@queens.ox.ac.uk from the mailing list queens-it
Remove-SympaMailingListMember -Sympa $Sympa -MailingList queens-it -Member jim.bob@queens.ox.ac.uk
.EXAMPLE
Remove the members jim.bob@queens.ox.ac.uk and jim.kirk@queens.ox.ac.uk from the mailing list queens-it
Remove-SympaMailingListMember -Sympa $Sympa -MailingList queens-it -Member @('jim.bob@queens.ox.ac.uk','jim.kirk@queens.ox.ac.uk')
.EXAMPLE
Remove all of the members from the queens-it mailling list
Get-SympaMailingListMember -Sympa $sympa -MailingList queens-it | Remove-SympaMailingListMember -Sympa $sympa -MailingList queens-it
.Example
Remove members from the list queens-it as defined in a CSV
Import-Csv C:\Sympa\queens-it-memberslist.csv | Remove-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 remove the member(s) from")]
[String]$MailingList,
[Parameter(Mandatory=$true,HelpMessage="Enter the address of the member(s) you want to remove from the Mailling list",ValueFromPipelineByPropertyName=$True)]
[Array]$Member
<#
[Parameter(Mandatory=$false,HelpMessage="Should you notify the user that they are being removed from 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 = "0"}
'No' {$Alert = "1"}
Default {$Alert = "1"}
}
#>
Process{
#Loop over the member(s) and remove them from the list
foreach($Address in $Member){
try
{
Write-Verbose "Removing $Address from $MailingList"
$Sympa.del("$MailingList","$Address",'1')
}
catch
{
}
}
}
}