This script can be used to generate a report about E-Mails which where permanently blocked. It is possible to filter the results for a specific time duration and sends the report only to specific or all affected users. This script only uses the NoSpamProxy Powershell Cmdlets to generate the report file.
The output contains the following information:
- sent time
- sender
- subject
Send-BlockReportToUsers\Send-BlockReportToUsers.ps1 -FromDate <String> [-ToDate <String>] [-ReportSender <String>] [-ReportSubject <String>] [-ReportFileName <String>] [-SmtpHost <String>] [-ReportRecipient <String[]>] [-ReportRecipientCSV <String>] [-CheckUserExistence] [-AdServer <String>] [-AdPort <Int32>] [-AdBaseDN <String>] [-AdReportGroup <String>] [-AdUsername <String>] [-TenantPrimaryDomain <String>] [<CommonParameters>]
Send-BlockReportToUsers\Send-BlockReportToUsers.ps1 -NoTime [-ReportSender <String>] [-ReportSubject <String>] [-ReportFileName <String>] [-SmtpHost <String>] [-ReportRecipient <String[]>] [-ReportRecipientCSV <String>] [-CheckUserExistence] [-AdServer <String>] [-AdPort <Int32>] [-AdBaseDN <String>] [-AdReportGroup <String>] [-AdUsername <String>] [-TenantPrimaryDomain <String>] [<CommonParameters>]
Send-BlockReportToUsers\Send-BlockReportToUsers.ps1 -NumberOfDaysToReport <String> [-ReportSender <String>] [-ReportSubject <String>] [-ReportFileName <String>] [-SmtpHost <String>] [-ReportRecipient <String[]>] [-ReportRecipientCSV <String>] [-CheckUserExistence] [-AdServer <String>] [-AdPort <Int32>] [-AdBaseDN <String>] [-AdReportGroup <String>] [-AdUsername <String>] [-TenantPrimaryDomain <String>] [<CommonParameters>]
Send-BlockReportToUsers\Send-BlockReportToUsers.ps1 -NumberOfHoursToReport <Int32> [-ReportSender <String>] [-ReportSubject <String>] [-ReportFileName <String>] [-SmtpHost <String>] [-ReportRecipient <String[]>] [-ReportRecipientCSV <String>] [-CheckUserExistence] [-AdServer <String>] [-AdPort <Int32>] [-AdBaseDN <String>] [-AdReportGroup <String>] [-AdUsername <String>] [-TenantPrimaryDomain <String>] [<CommonParameters>]
Send-BlockReportToUsers\Send-BlockReportToUsers.ps1 -ReportInterval <String> [-ReportSender <String>] [-ReportSubject <String>] [-ReportFileName <String>] [-SmtpHost <String>] [-ReportRecipient <String[]>] [-ReportRecipientCSV <String>] [-CheckUserExistence] [-AdServer <String>] [-AdPort <Int32>] [-AdBaseDN <String>] [-AdReportGroup <String>] [-AdUsername <String>] [-TenantPrimaryDomain <String>] [<CommonParameters>]
Send-BlockReportToUsers\Send-BlockReportToUsers.ps1 -SetAdPassword [-ReportFileName <String>] [-TenantPrimaryDomain <String>] [<CommonParameters>]
Define the BaseDN for searching a user group in the defined AD.
Default: 389 Define a custom port to access the AD.
Define the AD user group to search for. The users in this group will receive a report.
Define the hostname, FQDN or IP address of the desired AD.
Define an optional username to authenticate against the AD. A password have to be set before using .
The switch allows to check each report recipient against the known NoSpamProxy users.
Only usable if no recipient list is provided.
Can have a huge performance impact.
Mandatory if you like to use a timespan.
Specifies the start date for the E-Mail filter.
Please use ISO 8601 date format: "YYYY-MM-DD hh:mm:ss"
E.g.:
"2019-06-05 08:00" or "2019-06-05 20:00:00:00"
Set a file path to an CSV file containing a list of original E-Mail recipient to filter for. Be aware about the needed CSV format, please watch the provided example.
Mandatory if you do not like to specify a time value in any kind of way.
No value needs to be passed here <NoTime> is just a single switch.
Specify a rule name which is defined in NSP as E-Mail filter.
Mandatory if you like to use a number of days for filtering.
Specifies the number of days for which th E-Mails should be filtered.
Mandatory if you like to use a number of hours for filtering.
Specifies the number of hours for which th E-Mails should be filtered.
Default: reject-analysis
Define a part of the complete file name.
E.g.: 2019-06-05-msgTrackReport.csv
Mandatory if you like to use a predefined timespan.
Specifies a predefined timespan.
Possible values are:
daily, monthly, weekly
The report will start at 00:00:00 o'clock and ends at 23:59:59 o'clock.
The script call must be a day after the desired report end day.
Specifies the E-Mail recipient. It is possible to pass a comma separated list to address multiple recipients.
E.g.: [email protected], [email protected]
Set a filepath to an CSV file containing a list of report E-Mail recipient. Be aware about the needed CSV format, please watch the provided example.
Default: NoSpamProxy Report Sender <[email protected]>
Sets the report E-Mail sender address.
Default: Auswertung der abgewiesenen E-Mails an Sie
Sets the report E-Mail subject.
Set a password to use for authentication against the AD. The password will be saved as encrypted "NspAdReportingPass.bin" file under %APPDATA%.
Specifies the SMTP host which should be used to send the report E-Mail.
It is possible to use a FQDN or IP address.
Used to login into the desired NoSpamProxy tenant to run this script on.
Only required if NoSpamProxy v14 is used in provider mode.
Optional if you like to use a timespan.
Specifies the end date for the E-Mail filter.
Please use ISO 8601 date format: "YYYY-MM-DD hh:mm:ss"
E.g.:
"2019-06-05 08:00" or "2019-06-05 20:00:00"
Report is stored under %TEMP% if the report is send via E-Mail the file will be removed.
Send-BlockReportToUsers.ps1 -NoTime -ReportFileName "Example-Report" -ReportRecipient [email protected] -ReportSender "NoSpamProxy Report Sender \<nospamproxy@example.com>" -ReportSubject "Example Report" -SmtpHost mail.example.com
Send-BlockReportToUsers.ps1 -FromDate: "2019-06-05 08:00:00" -ToDate: "2019-06-05 20:00:00"
It is mandatory to specify <FromDate>. Instead <ToDate> is optional.
These parameters can be combined with all other parameters except <NumberOfDaysToReport>, <NumberOfHoursToRepor>, <ReportIntervall> and <NoTime>.
Send-BlockReportToUsers.ps1 -NumberOfDaysToReport 7
You can combine <NumberOfDaysToReport> with all other parameters except <FromDate>, <ToDate>, <NumberOfHoursToRepor>, <ReportIntervall> and <NoTime>.
Send-BlockReportToUsers.ps1 -NumberOfHoursToReport 12
You can combine <NumberOfHoursToReport> with all other parameters except <FromDate>, <ToDate>, <NumberOfDaysToReport>, <ReportIntervall> and <NoTime>.
Send-BlockReportToUsers.ps1 -ReportInterval weekly
You can combine <ReportInterval> with all other parameters except <FromDate>, <ToDate>, <NumberOfDaysToReport>, <NumberOfHoursToReport>, <ReportIntervall> and <NoTime>.
Send-BlockReportToUsers.ps1 -NoTime -NspRule "All other inbound mails"
Send-BlockReportToUsers.ps1 -NoTime -SmtpHost mail.example.com -ReportRecipientCSV "C:\Users\example\Documents\email-report.csv"
The CSV have to contain the header "Email" else the mail addresses cannot be read from the file.
It is possible to combine <ReportRecipientCSV> with <ReportRecipient>.
E.g: email-report.csv
User,Email
user1,[email protected]
user2,[email protected]
Send-BlockReportToUsers.ps1 -NoTime -AdServer ad.example.com -AdBaseDN "DC=example,DC=com" -AdReportGroup "MyReportGroup"
Connect to AD as anonymous.
Send-BlockReportToUsers.ps1 -NoTime -AdServer ad.example.com -AdBaseDN "DC=example,DC=com" -AdReportGroup "MyReportGroup" -AdUsername Administrator
Connect to AD as Administrator, password needs to be set using .\Send-BlockReportToUsers.ps1 -SetAdPassword
Send-BlockReportToUsers.ps1 -SetAdPassword
Will wait for a user input. The input is shown in plain text!