Import email addresses to SpamTitan (API) whitelist filter from text file with PowerShell

I've created this PowerShell script to import email addresses into SpamTitan (API) global whitelist filter from a text file. Feel free to use it as long as you link to this article on your site or in your script:


<#
Created by Allan Brochorst Kjær. Script must not be changed and/or copied without written permission from the author.
Source file must contain an e-mail address on each line, e.g.:
user1@test.com
user2@test.com
user3@test.com
#>
Remove-Item c:\SpamTitan_ImportAddress_log.txt
date >>c:\SpamTitan_ImportAddress_log.txt
$data1 = Get-Content "\\fileshare\source1.txt" | Select-String "@"
$data2 = Get-Content "\\fileshare\source2.txt" | Select-String "@"
$data3 = Get-Content "\\fileshare\source3.txt" | Select-String "@"
Foreach ($i in $data1)
{
$i >>c:\SpamTitan_ImportAddress_log.txt
#The wget alias does not work in PowerShell 3, using Invoke-WebRequest instead
#wget https://yourSpamTitanURLhere.site.com/whitelist/add?sender=$i
Invoke-WebRequest https://yourSpamTitanURLhere.site.com/whitelist/add?sender=$i >>c:\SpamTitan_ImportAddress_log.txt
}
Foreach ($i in $data2)
{
$i >>c:\SpamTitan_ImportAddress_log.txt
#wget https://yourSpamTitanURLhere.site.com/whitelist/add?sender=$i
Invoke-WebRequest https://yourSpamTitanURLhere.site.com/whitelist/add?sender=$i >>c:\SpamTitan_ImportAddress_log.txt
}
Foreach ($i in $data3)
{
$i >>c:\SpamTitan_ImportAddress_log.txt
#wget https://yourSpamTitanURLhere.site.com/whitelist/add?sender=$i
Invoke-WebRequest https://yourSpamTitanURLhere.site.com/whitelist/add?sender=$i >>c:\SpamTitan_ImportAddress_log.txt
}
date >>c:\SpamTitan_ImportAddress_log.txt

Kommentarer

Populære opslag fra denne blog

Microsoft Office 2016 and the AUTO_ACTIVATE property

Access Exchange online with Office 365 multi-factor authentication (MFA/2FA)

Disable logon and logoff events (event id 4624, 4625, 4634 (and all the other ones...))