├── Get-NspMsgTrackAsCSV ├── email-recipient.csv.txt ├── Get-NspMsgTrackAsCSV.ps1 └── Readme.md ├── Get-NspLicenseReport_(Database) ├── email-recipient.csv.txt ├── Get-NspLicenseReport.ps1 ├── Get-NspLicenseReportForMsp.ps1 ├── LicenseUsageUsers_v13.sql ├── LicenseUsageDomains_v13.sql ├── LicenseUsageUsers_v14.sql ├── LicenseUsageDomains_v14.sql └── Readme.md ├── Get-DMARCReport ├── Get-DMARCReport.ps1 └── README.md ├── Get-NspTlsReport ├── TLSReport-Example.html ├── Readme.md └── Get-NspTlsReport.ps1 ├── 11.x ├── Get-DMARCReport │ ├── Get-DMARCReport.ps1 │ └── README.md ├── Get-RejectionReport │ ├── Get-RejectionReport.ps1 │ └── README.md ├── Send-ReporttoUsersWithBlockedEmails │ ├── Send-ReportToUsersWithBlockedEmails.ps1 │ └── README.md └── Send-ReporttoUserswithBlockedEmailsWithAttachment │ ├── Send-ReporttoUserswithBlockedEmailsWithAttachment.ps1 │ └── README.md ├── Get-NspSandboxStatistic ├── Get-NspSandboxStatistic.ps1 └── Readme.md ├── Send-BlockReportToUsers ├── Send-BlockReportToUsers.ps1 └── Readme.md ├── Send-EncryptReportToUsers ├── Send-EncryptReportToUsers.ps1 └── Readme.md ├── get-expiredTLSCertificates ├── get-expiredTLSCertificates.ps1 └── README.md ├── get-certificatesInQuarantine ├── get-certificatesInQuarantine.ps1 └── README.md ├── Send-ReporttoUserswithBlockedEmails ├── Send-ReportToUsersWithBlockedEmails.ps1 └── README.md ├── Send-ReporttoUserswithBlockedEmailsWithAttachment ├── Send-ReporttoUserswithBlockedEmailsWithAttachment.ps1 └── README.md ├── Get-RejectionReport (Database) ├── Filters.sql ├── Filters_v14.sql ├── UnknownRecipients_Old.sql ├── Actions.sql ├── UnknownRecipients_Current.sql ├── TopSpammers.sql ├── Actions_v14.sql ├── UnknownRecipients_v14.sql ├── TopAddresses.sql ├── TopSpammers_v14.sql ├── BlockedMessageTracks.sql ├── TopAddresses_v14.sql ├── BlockedMessageTracks_v14.sql ├── README.md └── Get-RejectionReport.ps1 ├── Get-EncryptionReport ├── README.md └── Get-EncryptionReport.ps1 ├── Get-NspLicenseReport ├── Readme.md └── Get-NspLicenseReport.ps1 ├── Get-RejectionReport (WebServices) ├── README.md └── Get-RejectionReport.ps1 ├── README.md └── LICENSE /Get-NspMsgTrackAsCSV/email-recipient.csv.txt: -------------------------------------------------------------------------------- 1 | User,Email 2 | alice,alice@jaj.test 3 | bob,bob@jaj.test -------------------------------------------------------------------------------- /Get-NspLicenseReport_(Database)/email-recipient.csv.txt: -------------------------------------------------------------------------------- 1 | User,Email 2 | alice,alice@jaj.test 3 | bob,bob@jaj.test -------------------------------------------------------------------------------- /Get-DMARCReport/Get-DMARCReport.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noSpamProxy/Reports/HEAD/Get-DMARCReport/Get-DMARCReport.ps1 -------------------------------------------------------------------------------- /Get-NspTlsReport/TLSReport-Example.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noSpamProxy/Reports/HEAD/Get-NspTlsReport/TLSReport-Example.html -------------------------------------------------------------------------------- /11.x/Get-DMARCReport/Get-DMARCReport.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noSpamProxy/Reports/HEAD/11.x/Get-DMARCReport/Get-DMARCReport.ps1 -------------------------------------------------------------------------------- /Get-NspMsgTrackAsCSV/Get-NspMsgTrackAsCSV.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noSpamProxy/Reports/HEAD/Get-NspMsgTrackAsCSV/Get-NspMsgTrackAsCSV.ps1 -------------------------------------------------------------------------------- /11.x/Get-RejectionReport/Get-RejectionReport.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noSpamProxy/Reports/HEAD/11.x/Get-RejectionReport/Get-RejectionReport.ps1 -------------------------------------------------------------------------------- /Get-NspSandboxStatistic/Get-NspSandboxStatistic.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noSpamProxy/Reports/HEAD/Get-NspSandboxStatistic/Get-NspSandboxStatistic.ps1 -------------------------------------------------------------------------------- /Send-BlockReportToUsers/Send-BlockReportToUsers.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noSpamProxy/Reports/HEAD/Send-BlockReportToUsers/Send-BlockReportToUsers.ps1 -------------------------------------------------------------------------------- /Get-NspLicenseReport_(Database)/Get-NspLicenseReport.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noSpamProxy/Reports/HEAD/Get-NspLicenseReport_(Database)/Get-NspLicenseReport.ps1 -------------------------------------------------------------------------------- /Send-EncryptReportToUsers/Send-EncryptReportToUsers.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noSpamProxy/Reports/HEAD/Send-EncryptReportToUsers/Send-EncryptReportToUsers.ps1 -------------------------------------------------------------------------------- /get-expiredTLSCertificates/get-expiredTLSCertificates.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noSpamProxy/Reports/HEAD/get-expiredTLSCertificates/get-expiredTLSCertificates.ps1 -------------------------------------------------------------------------------- /get-certificatesInQuarantine/get-certificatesInQuarantine.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noSpamProxy/Reports/HEAD/get-certificatesInQuarantine/get-certificatesInQuarantine.ps1 -------------------------------------------------------------------------------- /Get-NspLicenseReport_(Database)/Get-NspLicenseReportForMsp.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noSpamProxy/Reports/HEAD/Get-NspLicenseReport_(Database)/Get-NspLicenseReportForMsp.ps1 -------------------------------------------------------------------------------- /Send-ReporttoUserswithBlockedEmails/Send-ReportToUsersWithBlockedEmails.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noSpamProxy/Reports/HEAD/Send-ReporttoUserswithBlockedEmails/Send-ReportToUsersWithBlockedEmails.ps1 -------------------------------------------------------------------------------- /11.x/Send-ReporttoUsersWithBlockedEmails/Send-ReportToUsersWithBlockedEmails.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noSpamProxy/Reports/HEAD/11.x/Send-ReporttoUsersWithBlockedEmails/Send-ReportToUsersWithBlockedEmails.ps1 -------------------------------------------------------------------------------- /Send-ReporttoUserswithBlockedEmailsWithAttachment/Send-ReporttoUserswithBlockedEmailsWithAttachment.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noSpamProxy/Reports/HEAD/Send-ReporttoUserswithBlockedEmailsWithAttachment/Send-ReporttoUserswithBlockedEmailsWithAttachment.ps1 -------------------------------------------------------------------------------- /11.x/Send-ReporttoUserswithBlockedEmailsWithAttachment/Send-ReporttoUserswithBlockedEmailsWithAttachment.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noSpamProxy/Reports/HEAD/11.x/Send-ReporttoUserswithBlockedEmailsWithAttachment/Send-ReporttoUserswithBlockedEmailsWithAttachment.ps1 -------------------------------------------------------------------------------- /Get-RejectionReport (Database)/Filters.sql: -------------------------------------------------------------------------------- 1 | declare @startdate datetime = convert(datetime, '{0}', 104) 2 | declare @enddate datetime = convert(datetime, '{1}', 104) 3 | 4 | select 5 | name, 6 | count(*) Count 7 | from MessageTracking.Filter f 8 | join MessageTracking.MessageTrackEntry m 9 | on f.MessageTrackId = m.id 10 | where m.Sent > @startdate and m.Sent < @enddate and (m.status = 3 or m.status = 4) and (f.Scl > 0) 11 | group by name -------------------------------------------------------------------------------- /Get-RejectionReport (Database)/Filters_v14.sql: -------------------------------------------------------------------------------- 1 | declare @startdate datetime = convert(datetime, '{0}', 104) 2 | declare @enddate datetime = convert(datetime, '{1}', 104) 3 | declare @tenantId int = '{2}'; 4 | 5 | select 6 | name, 7 | count(*) Count 8 | from MessageTracking.Filter f 9 | join MessageTracking.MessageTrackEntry m 10 | on f.MessageTrackId = m.id AND m.TenantId = f.TenantId 11 | where m.Sent > @startdate and m.Sent < @enddate and (m.status = 3 or m.status = 4) and (f.Scl > 0) AND m.TenantId = @tenantId 12 | group by name -------------------------------------------------------------------------------- /Get-RejectionReport (Database)/UnknownRecipients_Old.sql: -------------------------------------------------------------------------------- 1 | declare @startdate datetime = convert(datetime, '{0}', 104) 2 | declare @enddate datetime = convert(datetime, '{1}', 104) 3 | 4 | select count(*) from messagetracking.messagetrackentry mt 5 | where WasReceivedFromRelayServer = 0 and Sent > @startdate and Sent < @enddate and not exists ( 6 | select 1 7 | from messagetracking.deliveryattempt da 8 | where da.MessageTrackId = mt.id and (da.Status <> 4 or da.StatusMessage <> N'Recipient unknown' OR da.StatusMessage is null) 9 | ) 10 | 11 | -------------------------------------------------------------------------------- /Get-RejectionReport (Database)/Actions.sql: -------------------------------------------------------------------------------- 1 | declare @startdate datetime = convert(datetime, '{0}', 104) 2 | declare @enddate datetime = convert(datetime, '{1}', 104) 3 | 4 | select 5 | name, 6 | case 7 | when Decision = 2 then 'Temporary Blocked' 8 | when Decision = 3 then 'Permanently Blocked' 9 | end Decision, 10 | count(*) Count 11 | from MessageTracking.Action a 12 | join MessageTracking.MessageTrackEntry m 13 | on a.MessageTrackId = m.id 14 | where m.Sent >@startdate and m.Sent < @enddate and (m.status = 3 or m.status = 4) and (Decision = 2 or Decision = 3) 15 | group by name, Decision 16 | -------------------------------------------------------------------------------- /Get-RejectionReport (Database)/UnknownRecipients_Current.sql: -------------------------------------------------------------------------------- 1 | declare @startdate datetime = convert(datetime, '{0}', 104) 2 | declare @enddate datetime = convert(datetime, '{1}', 104) 3 | 4 | select count(*) id from messagetracking.messagetrackentry mt 5 | where WasReceivedFromRelayServer = 0 and Sent > @startdate and Sent < @enddate and not exists ( 6 | select 1 7 | from messagetracking.messageaddress mr 8 | join messagetracking.deliveryattempt da on da.MessageAddressId = mr.Id 9 | where mr.MessageTrackId = mt.id and (da.Status <> 4 or da.StatusMessage <> 'Recipient unknown' OR da.StatusMessage is null) 10 | ) 11 | -------------------------------------------------------------------------------- /Get-RejectionReport (Database)/TopSpammers.sql: -------------------------------------------------------------------------------- 1 | declare @startdate datetime = convert(datetime, '{0}', 104) 2 | declare @enddate datetime = convert(datetime, '{1}', 104) 3 | 4 | select 5 | COUNT(*) AS Count, 6 | MessageTracking.MessageAddress.Address, 7 | MessageTracking.MessageAddress.Domain 8 | from MessageTracking.MessageTrackEntry 9 | join MessageTracking.MessageAddress 10 | on MessageTracking.MessageAddress.MessageTrackId = MessageTracking.MessageTrackEntry.Id 11 | where Sent > @startdate and Sent < @enddate and (status = 3 or status = 4) and MessageTracking.MessageAddress.AddressType = 2 12 | group by Address, Domain, AddressType 13 | order by Count desc -------------------------------------------------------------------------------- /Get-RejectionReport (Database)/Actions_v14.sql: -------------------------------------------------------------------------------- 1 | declare @startdate datetime = convert(datetime, '{0}', 104) 2 | declare @enddate datetime = convert(datetime, '{1}', 104) 3 | declare @tenantId int = '{2}'; 4 | 5 | select 6 | name, 7 | case 8 | when Decision = 2 then 'Temporary Blocked' 9 | when Decision = 3 then 'Permanently Blocked' 10 | end Decision, 11 | count(*) Count 12 | from MessageTracking.Action a 13 | join MessageTracking.MessageTrackEntry m 14 | on a.MessageTrackId = m.id AND a.TenantId = m.TenantId 15 | where m.Sent >@startdate and m.Sent < @enddate and m.status IN (3,4) and Decision IN (2,3) AND m.TenantId = @tenantId 16 | group by name, Decision 17 | -------------------------------------------------------------------------------- /Get-RejectionReport (Database)/UnknownRecipients_v14.sql: -------------------------------------------------------------------------------- 1 | declare @startdate datetime = convert(datetime, '{0}', 104) 2 | declare @enddate datetime = convert(datetime, '{1}', 104) 3 | declare @tenantId int = '{2}'; 4 | 5 | select count(*) id from messagetracking.messagetrackentry mt 6 | where WasReceivedFromRelayServer = 0 and Sent > @startdate and Sent < @enddate and not exists ( 7 | select 1 8 | from messagetracking.messageaddress mr 9 | join messagetracking.deliveryattempt da on da.MessageAddressId = mr.Id AND mr.TenantId = da.TenantId 10 | where mr.MessageTrackId = mt.id and (da.Status <> 4 or da.StatusMessage <> 'Recipient unknown' OR da.StatusMessage is null) AND mr.TenantId = @tenantId 11 | ) 12 | -------------------------------------------------------------------------------- /Get-RejectionReport (Database)/TopAddresses.sql: -------------------------------------------------------------------------------- 1 | declare @startdate datetime = convert(datetime, '{0}', 104) 2 | declare @enddate datetime = convert(datetime, '{1}', 104) 3 | 4 | select 5 | COUNT(*) AS Count, 6 | MessageTracking.MessageAddress.Address, 7 | MessageTracking.MessageAddress.Domain, 8 | case 9 | when AddressType = 1 then 'Recipient' 10 | when AddressType = 2 then 'Sender' 11 | end AddressType 12 | from MessageTracking.MessageTrackEntry 13 | join MessageTracking.MessageAddress 14 | on MessageTracking.MessageAddress.MessageTrackId = MessageTracking.MessageTrackEntry.Id 15 | where Sent > @startdate and Sent < @enddate and (status = 1) 16 | group by Address, Domain, AddressType 17 | order by Count desc -------------------------------------------------------------------------------- /Get-RejectionReport (Database)/TopSpammers_v14.sql: -------------------------------------------------------------------------------- 1 | declare @startdate datetime = convert(datetime, '{0}', 104) 2 | declare @enddate datetime = convert(datetime, '{1}', 104) 3 | declare @tenantId int = '{2}'; 4 | 5 | select 6 | COUNT(*) AS Count, 7 | MessageTracking.MessageAddress.Address, 8 | MessageTracking.MessageAddress.Domain 9 | from MessageTracking.MessageTrackEntry 10 | join MessageTracking.MessageAddress 11 | on MessageTracking.MessageAddress.MessageTrackId = MessageTracking.MessageTrackEntry.Id AND MessageTracking.MessageAddress.TenantId = MessageTracking.MessageTrackEntry.TenantId 12 | where Sent > @startdate and Sent < @enddate and status in (3,4) and MessageTracking.MessageAddress.AddressType = 2 AND MessageTracking.MessageTrackEntry.TenantId = @tenantId 13 | group by Address, Domain, AddressType 14 | order by Count desc -------------------------------------------------------------------------------- /Get-RejectionReport (Database)/BlockedMessageTracks.sql: -------------------------------------------------------------------------------- 1 | declare @startdate datetime = convert(datetime, '{0}', 104) 2 | declare @enddate datetime = convert(datetime, '{1}', 104) 3 | 4 | select 5 | case 6 | when WasReceivedFromRelayServer = 0 then 'Inbound' 7 | when WasReceivedFromRelayServer = 1 then 'Outbound' 8 | else 'Summary' 9 | end Direction, 10 | case 11 | when Status = 1 then 'Success' 12 | when Status = 3 then 'Temporary Blocked' 13 | when Status = 4 then 'Permanently Blocked' 14 | when Status = 6 then 'PartialSuccess' 15 | when Status = 9 then 'Put on Hold' 16 | when Status is null then 'Summary' 17 | end Status, 18 | COUNT(*) Count 19 | from MessageTracking.MessageTrackEntry 20 | where Sent > @startdate and Sent < @enddate and (status = 1 or status = 3 or status = 4 or Status = 6 or status = 9) 21 | group by rollup (WasReceivedFromRelayServer, status) -------------------------------------------------------------------------------- /Get-RejectionReport (Database)/TopAddresses_v14.sql: -------------------------------------------------------------------------------- 1 | declare @startdate datetime = convert(datetime, '{0}', 104) 2 | declare @enddate datetime = convert(datetime, '{1}', 104) 3 | declare @tenantId int = '{2}'; 4 | 5 | select 6 | COUNT(*) AS Count, 7 | MessageTracking.MessageAddress.Address, 8 | MessageTracking.MessageAddress.Domain, 9 | case 10 | when AddressType = 1 then 'Recipient' 11 | when AddressType = 2 then 'Sender' 12 | end AddressType 13 | from MessageTracking.MessageTrackEntry 14 | join MessageTracking.MessageAddress 15 | on MessageTracking.MessageAddress.MessageTrackId = MessageTracking.MessageTrackEntry.Id AND MessageTracking.MessageAddress.TenantId = MessageTracking.MessageTrackEntry.TenantId 16 | where Sent > @startdate and Sent < @enddate and (status = 1) AND MessageTracking.MessageTrackEntry.TenantId = @tenantId 17 | group by Address, Domain, AddressType 18 | order by Count desc -------------------------------------------------------------------------------- /Get-RejectionReport (Database)/BlockedMessageTracks_v14.sql: -------------------------------------------------------------------------------- 1 | declare @startdate datetime = convert(datetime, '{0}', 104) 2 | declare @enddate datetime = convert(datetime, '{1}', 104) 3 | declare @tenantId int = '{2}'; 4 | 5 | select 6 | case 7 | when WasReceivedFromRelayServer = 0 then 'Inbound' 8 | when WasReceivedFromRelayServer = 1 then 'Outbound' 9 | else 'Summary' 10 | end Direction, 11 | case 12 | when Status = 1 then 'Success' 13 | when Status = 3 then 'Temporary Blocked' 14 | when Status = 4 then 'Permanently Blocked' 15 | when Status = 6 then 'PartialSuccess' 16 | when Status = 9 then 'Put on Hold' 17 | when Status is null then 'Summary' 18 | end Status, 19 | COUNT(*) Count 20 | from MessageTracking.MessageTrackEntry 21 | where Sent > @startdate and Sent < @enddate and status IN (1,3,4,6,9) AND TenantId = @tenantId 22 | group by rollup (WasReceivedFromRelayServer, status) -------------------------------------------------------------------------------- /Get-EncryptionReport/README.md: -------------------------------------------------------------------------------- 1 | # Get-EncryptionReport.ps1 2 | This script generates a report over the count of encrypted and non encrypted mails. It seperates results in both directions and timespan (last 30 days and 30 days before that timespan). 3 | Report will be send as HTML attachment to a provided email address. 4 | 5 | ## Usage 6 | ```ps 7 | Get-EncryptionReport.ps1 [-smtphost ] [-ReportSender ] [-ReportRecipient ] 8 | ``` 9 | 10 | ## Parameters 11 | ### smtphost 12 | Specifies the Hostname or IP of the mailserver the report will be sent to. 13 | 14 | ### ReportSender 15 | Specifies the mailaddress used as sender for the report. 16 | 17 | ### ReportRecipient 18 | Specifies the recipient address for the report. 19 | 20 | ## Examples 21 | ### Example 1 22 | ```ps 23 | .\Get-EncryptionReport.ps1 -smtphost "mailserver.company" -ReportSender "mailgateway@company" -ReportRecipient "admin@company" 24 | ``` -------------------------------------------------------------------------------- /Get-NspLicenseReport/Readme.md: -------------------------------------------------------------------------------- 1 | # Get-NspLicenseReport.ps1 2 | 3 | Generates a report for the usage of each module containing the following information: 4 | 5 | - Total Users who used the module 6 | - List of each user who used the module 7 | 8 | It is also possible to generate a domain based license report, please the alternative script therefore: 9 | [Get-NspLicenseReport_(Database)](https://github.com/noSpamProxy/Reports/tree/master/Get-NspLicenseReport_(Database)) 10 | 11 | 12 | ## Usage 13 | 14 | ```ps 15 | Get-NspLicenseReport -ExportFilePath "PATH_TO_EXPORT_FILE" 16 | ``` 17 | 18 | - **ExportFilePath**: Mandatory. Specifies the path where the report will be saved. 19 | 20 | ## Example 21 | 22 | ```ps 23 | .\Get-NspLicenseReport.ps1 -ExportFilePath "C:\example\Usage.txt" 24 | ``` 25 | 26 | ## Supported NoSpamProxy Versions 27 | This script works for NoSpamProxy version 13 or higher. It depends on PowerShell version 4 (will be checked automatically). 28 | -------------------------------------------------------------------------------- /11.x/Send-ReporttoUsersWithBlockedEmails/README.md: -------------------------------------------------------------------------------- 1 | # Send-ReporttoUserswithAllBlockedEmails.ps1 2 | 3 | Sends a report to every E-Mail address that contains all permanently blocked E-Mails in a specific period of time. The report contains: 4 | 5 | - DeliveryStartTime 6 | - Sender address 7 | - Recipient address 8 | - Subject 9 | 10 | ## Usage 11 | 12 | ```ps 13 | Send-ReporttoUserswithAllBlockedEmails -SMTPHost [-NumberOfDaysToReport] [-ReportSender] [-ReportSubject]` 14 | ``` 15 | 16 | - **SMTPHost**: Mandatory. Specifies the SMTP Host which will be used to send the email. 17 | - **NumberOfDaysToReport**: Optional. Specifies the Number of days to report. Default value is "1". 18 | - **ReportSender**: Optional. Specifies the Sender of the email. Default value is "NoSpamProxy Report Sender ". 19 | - **ReportSubject**: Optional. Specifies the Subject of the email. Default value is "Auswertung". 20 | 21 | ## Example 22 | 23 | ```ps 24 | .\Send-ReporttoUserswithAllBlockedEmails.ps1 -SMTPHost mail.example.com` 25 | ``` 26 | 27 | ## Supported NoSpamProxy Versions 28 | 29 | This Script works with NoSpamProxy 11.x. 30 | -------------------------------------------------------------------------------- /11.x/Send-ReporttoUserswithBlockedEmailsWithAttachment/README.md: -------------------------------------------------------------------------------- 1 | # Send-ReporttoUserswithBlockedEmailsWithAttachment.ps1 2 | 3 | Sends a report to every E-Mail address that contains all permanently blocked E-Mails in a specific period of time that have been blocked because of an attachment. The report contains: 4 | 5 | - DeliveryStartTime 6 | - Sender address 7 | - Subject 8 | - Name of blocked file 9 | 10 | ## Usage 11 | 12 | ```ps 13 | Send-ReporttoUserswithBlockedEmailsWithAttachment -SMTPHost [-NumberOfDaysToReport] [-ReportSender] [-ReportSubject] 14 | ``` 15 | 16 | - **SMTPHost**: Mandatory. Specifies the SMTP Host which will be used to send the email. 17 | - **NumberOfDaysToReport**: Optional. Specifies the Number of days to report. Default value is "1". 18 | - **ReportSender**: Optional. Specifies the Sender of the email. Default value is "NoSpamProxy Report Sender ". 19 | - **ReportSubject**: Optional. Specifies the Subject of the email. Default value is "Auswertung". 20 | 21 | ## Example 22 | 23 | ```ps 24 | .\Send-ReporttoUserswithBlockedEmailsWithAttachment.ps1 -SMTPHost mail.example.com` 25 | ``` 26 | 27 | ## Supported NoSpamProxy Versions 28 | 29 | This Script works for every NoSpamProxy version 11.x. -------------------------------------------------------------------------------- /get-certificatesInQuarantine/README.md: -------------------------------------------------------------------------------- 1 | # get-certificatesInQuarantine.ps1 2 | Sends a report to the specified E-Mail address which contains a list of certificates in the certificate quarantine. If no certificates are in the quarantine, no report is sent. The report contains the following information: 3 | - SubjectDistinguishedName 4 | - IssuerDistinguishedName 5 | - ValidTo 6 | 7 | 8 | ### Usage 9 | `get-certificatesInQuarantine.ps1 -SMTPHost -ReportRecipient [-ReportSubject] [-ReportSender]` 10 | 11 | - SMTPHost 12 | ``` 13 | Mandatory. Specifies the SMTP Host which will be used to send the email. 14 | ``` 15 | - ReportRecipient 16 | ``` 17 | Mandatory. Specifies the Recipient of the email. 18 | ``` 19 | - ReportSubject 20 | ``` 21 | Optional. Specifies the Subject of the email. Default value is "DMARC Auswertung der letzten Woche". 22 | ``` 23 | - ReportSender 24 | ``` 25 | Optional. Specifies the Sender of the email. Default value is "NoSpamProxy Report Sender ". 26 | ``` 27 | 28 | ### Example 29 | `.\get-certificatesInQuarantine.ps1 -SMTPHost mail.example.com -ReportRecipient admin@example.com` 30 | 31 | ### Supported NoSpamProxy Versions 32 | This Script works for every NoSpamProxy version 12.1 and higher. 33 | -------------------------------------------------------------------------------- /Send-ReporttoUserswithBlockedEmails/README.md: -------------------------------------------------------------------------------- 1 | # Send-ReporttoUserswithAllBlockedEmails.ps1 2 | 3 | Sends a report to every E-Mail address that contains all permanently blocked E-Mails in a specific period of time. The report contains: 4 | 5 | - DeliveryStartTime 6 | - Sender address 7 | - Recipient address 8 | - Subject 9 | 10 | ## Usage 11 | 12 | ```ps 13 | Send-ReporttoUserswithAllBlockedEmails -SMTPHost [-NumberOfDaysToReport] [-ReportSender] [-ReportSubject]` 14 | ``` 15 | 16 | - **SMTPHost**: Mandatory. Specifies the SMTP Host which will be used to send the email. 17 | - **NumberOfDaysToReport**: Optional. Specifies the Number of days to report. Default value is "1". 18 | - **ReportSender**: Optional. Specifies the Sender of the email. Default value is "NoSpamProxy Report Sender ". 19 | - **ReportSubject**: Optional. Specifies the Subject of the email. Default value is "Auswertung". 20 | - **TenantPrimaryDomain**: Necessary to use if the provider mode for v14 is enabled. It specifies the desired tenant for the runtime environment. 21 | 22 | ## Example 23 | 24 | ```ps 25 | .\Send-ReporttoUserswithAllBlockedEmails.ps1 -SMTPHost mail.example.com` 26 | ``` 27 | 28 | ## Supported NoSpamProxy Versions 29 | 30 | This Script works with NoSpamProxy 12.2 and higher. 31 | -------------------------------------------------------------------------------- /get-expiredTLSCertificates/README.md: -------------------------------------------------------------------------------- 1 | # get-expiredTLSCertificates.ps1 2 | Sends a report to the specified E-Mail address which contains the following information: 3 | - Recipient Domain 4 | - Expiration Date of the certificate 5 | - IP-Address of the Target Server 6 | - Certificate Subject of the expired certificate 7 | 8 | ###Usage 9 | `get-expiredTLSCertificates -SMTPHost -ReportRecipient [-ReportSubject] [-NumberOfDaysToReport] [-ReportSender]` 10 | 11 | - SMTPHost 12 | ``` 13 | Mandatory. Specifies the SMTP Host which will be used to send the email. 14 | ``` 15 | - ReportRecipient 16 | ``` 17 | Mandatory. Specifies the Recipient of the email. 18 | ``` 19 | - ReportSubject 20 | ``` 21 | Optional. Specifies the Subject of the email. Default value is "Auswertung der abgelaufenen TLS-Zertifikate". 22 | ``` 23 | - NumberOfDaysToReport 24 | ``` 25 | Optional. Specifies the Number of days to report. Default value is "7". 26 | ``` 27 | - ReportSender 28 | ``` 29 | Optional. Specifies the Sender of the email. Default value is "NoSpamProxy Report Sender ". 30 | ``` 31 | 32 | ###Example 33 | `.\get-expiredTLSCertificates.ps1 -SMTPHost mail.example.com -ReportRecipient admin@example.com` 34 | 35 | ###Supported NoSpamProxy Versions 36 | This Script works for every NoSpamProxy version 11.x and 12.0. 37 | -------------------------------------------------------------------------------- /Send-ReporttoUserswithBlockedEmailsWithAttachment/README.md: -------------------------------------------------------------------------------- 1 | # Send-ReporttoUserswithBlockedEmailsWithAttachment.ps1 2 | 3 | Sends a report to every E-Mail address that contains all permanently blocked E-Mails in a specific period of time that have been blocked because of an attachment. The report contains: 4 | 5 | - DeliveryStartTime 6 | - Sender address 7 | - Subject 8 | - Name of blocked file 9 | 10 | ## Usage 11 | 12 | ```ps 13 | Send-ReporttoUserswithBlockedEmailsWithAttachment -SMTPHost [-NumberOfDaysToReport] [-ReportSender] [-ReportSubject] 14 | ``` 15 | 16 | - **SMTPHost**: Mandatory. Specifies the SMTP Host which will be used to send the email. 17 | - **NumberOfDaysToReport**: Optional. Specifies the Number of days to report. Default value is "1". 18 | - **ReportSender**: Optional. Specifies the Sender of the email. Default value is "NoSpamProxy Report Sender ". 19 | - **ReportSubject**: Optional. Specifies the Subject of the email. Default value is "Auswertung". 20 | - **TenantPrimaryDomain**: Necessary to use if the provider mode for v14 is enabled. It specifies the desired tenant for the runtime environment. 21 | 22 | ## Example 23 | 24 | ```ps 25 | .\Send-ReporttoUserswithBlockedEmailsWithAttachment.ps1 -SMTPHost mail.example.com` 26 | ``` 27 | 28 | ## Supported NoSpamProxy Versions 29 | 30 | This Script works for NoSpamProxy 12.x or later. 31 | -------------------------------------------------------------------------------- /Get-DMARCReport/README.md: -------------------------------------------------------------------------------- 1 | # Get-DMARCReport.ps1 2 | Sends a report to the specified E-Mail address which contains the following information for every successful inbound email: 3 | - Domain information from envelope 4 | - Domain information from Header 5 | - SPF Check result 6 | - SPF Alignment result 7 | - DKIM Check result 8 | - DKIM Alignment result 9 | - DMARC Check Result 10 | - DMARC Policy (Applicable DMARC policy) 11 | - What if (Effective policy) 12 | - Date 13 | - Message ID 14 | 15 | 16 | ###Usage 17 | `Get-DMARCReport -SMTPHost -ReportRecipient [-ReportSubject] [-NumberOfDaysToReport] [-ReportSender]` 18 | 19 | - SMTPHost 20 | ``` 21 | Mandatory. Specifies the SMTP Host which will be used to send the email. 22 | ``` 23 | - ReportRecipient 24 | ``` 25 | Mandatory. Specifies the Recipient of the email. 26 | ``` 27 | - ReportSubject 28 | ``` 29 | Optional. Specifies the Subject of the email. Default value is "DMARC Auswertung der letzten Woche". 30 | ``` 31 | - NumberOfDaysToReport 32 | ``` 33 | Optional. Specifies the Number of days to report. Default value is "7". 34 | ``` 35 | - ReportSender 36 | ``` 37 | Optional. Specifies the Sender of the email. Default value is "NoSpamProxy Report Sender ". 38 | ``` 39 | 40 | ###Example 41 | `.\Get-RejectionReport.ps1 -SMTPHost mail.example.com -ReportRecipient admin@example.com` 42 | 43 | ###Supported NoSpamProxy Versions 44 | This Script works for every NoSpamProxy version 12.2 and higher. 45 | -------------------------------------------------------------------------------- /11.x/Get-DMARCReport/README.md: -------------------------------------------------------------------------------- 1 | # Get-DMARCReport.ps1 2 | Sends a report to the specified E-Mail address which contains the following information for every successful inbound email: 3 | - Domain information from envelope 4 | - Domain information from Header 5 | - SPF Check result 6 | - SPF Alignment result 7 | - DKIM Check result 8 | - DKIM Alignment result 9 | - DMARC Check Result 10 | - DMARC Policy (Applicable DMARC policy) 11 | - What if (Effective policy) 12 | - Date 13 | - Message ID 14 | 15 | 16 | ###Usage 17 | `Get-DMARCReport -SMTPHost -ReportRecipient [-ReportSubject] [-NumberOfDaysToReport] [-ReportSender]` 18 | 19 | - SMTPHost 20 | ``` 21 | Mandatory. Specifies the SMTP Host which will be used to send the email. 22 | ``` 23 | - ReportRecipient 24 | ``` 25 | Mandatory. Specifies the Recipient of the email. 26 | ``` 27 | - ReportSubject 28 | ``` 29 | Optional. Specifies the Subject of the email. Default value is "DMARC Auswertung der letzten Woche". 30 | ``` 31 | - NumberOfDaysToReport 32 | ``` 33 | Optional. Specifies the Number of days to report. Default value is "7". 34 | ``` 35 | - ReportSender 36 | ``` 37 | Optional. Specifies the Sender of the email. Default value is "NoSpamProxy Report Sender ". 38 | ``` 39 | 40 | ###Example 41 | `.\Get-RejectionReport.ps1 -SMTPHost mail.example.com -ReportRecipient admin@example.com` 42 | 43 | ###Supported NoSpamProxy Versions 44 | This Script works for every NoSpamProxy version 11.0 and higher. 45 | -------------------------------------------------------------------------------- /11.x/Get-RejectionReport/README.md: -------------------------------------------------------------------------------- 1 | # Get-RejectionReport.ps1 2 | Sends a report to the specified E-Mail address which contains the following information: 3 | - Total count of processed emails. 4 | - Total count of sent emails. 5 | - Total count of received emails. 6 | - Total count of rejected emails. 7 | - Total count of rejected emails for each Filter and Action. 8 | 9 | 10 | ###Usage 11 | `Get-RejectionReport -SMTPHost -ReportRecipient [-ReportSubject] [-NumberOfDaysToReport] [-ReportSender]` 12 | 13 | - SMTPHost 14 | ``` 15 | Mandatory. Specifies the SMTP Host which will be used to send the email. 16 | ``` 17 | - ReportRecipient 18 | ``` 19 | Mandatory. Specifies the Recipient of the email. 20 | ``` 21 | - ReportSubject 22 | ``` 23 | Optional. Specifies the Subject of the email. Default value is "Auswertung". 24 | ``` 25 | - NumberOfDaysToReport 26 | ``` 27 | Optional. Specifies the Number of days to report. Default value is "7". 28 | ``` 29 | - ReportSender 30 | ``` 31 | Optional. Specifies the Sender of the email. Default value is "NoSpamProxy Report Sender ". 32 | ``` 33 | 34 | ###Example 35 | `.\Get-RejectionReport.ps1 -SMTPHost mail.example.com -ReportRecipient admin@example.com` 36 | 37 | ###Supported NoSpamProxy Versions 38 | This Script works for every NoSpamProxy version 11.x. NoSpamProxy version 12.x is NOT supported. For NoSpamProxy 12.x and higher please check https://github.com/noSpamProxy/Reports/tree/master/Get-RejectionReportNSP12x 39 | -------------------------------------------------------------------------------- /Get-RejectionReport (WebServices)/README.md: -------------------------------------------------------------------------------- 1 | # Get-RejectionReport.ps1 2 | 3 | Sends a report to the specified E-Mail address which contains the following information: 4 | 5 | - Total count of processed emails. 6 | - Total count of sent emails. 7 | - Total count of received emails. 8 | - Total count of rejected emails. 9 | - Total count of rejected emails for each Filter and Action. 10 | 11 | This version uses the NoSPamProxy WebServices to acquire the required information. This is suited for small to medium sized installations. For large installations, the [Database Version](../Get-RejectionReport%20(Database)) version instead. 12 | 13 | ## Usage 14 | 15 | ```ps 16 | Get-RejectionReport -SMTPHost -ReportRecipient [-ReportSubject] [-NumberOfDaysToReport] [-ReportSender]` 17 | ``` 18 | 19 | - **SMTPHost**: Mandatory. Specifies the SMTP Host which will be used to send the email. 20 | - **ReportRecipient**: Mandatory. Specifies the Recipient of the email. 21 | - **ReportSubject**: Optional. Specifies the Subject of the email. Default value is "Auswertung". 22 | - **ReportSender**: Mandatory. Specifies the Sender of the email. 23 | - **NumberOfDaysToReport**: Optional. Specifies the Number of days to report. Default value is "7". 24 | - **TopAddressesCount**: Optional. How many Addresses to include in the top Senders/Recipients/Spammers. Defaults to 5 25 | - **ExcludeFromTopAddresses**: Optional. Specify addresses to ignore when evaluating top Senders/Recipients. Useful for dropping obvious addresses from the list to get a more informative statistic 26 | 27 | ## Example 28 | 29 | ```ps 30 | .\Get-RejectionReport.ps1 -SMTPHost mail.example.com -ReportRecipient admin@example.com` -ReportSender "NoSpamProxy Report Sender " 31 | ``` 32 | 33 | ## Supported NoSpamProxy Versions 34 | 35 | This Script works for NoSpamProxy version 12.2 and higher. 36 | -------------------------------------------------------------------------------- /Get-NspLicenseReport_(Database)/LicenseUsageUsers_v13.sql: -------------------------------------------------------------------------------- 1 | WITH Query AS ( 2 | SELECT 3 | COALESCE (u.Displayname, s.Address) AS DisplayName, 4 | CASE WHEN SUM(s.MailsSent) = 0 THEN 0 ELSE 1 END AS Protection, 5 | CASE WHEN SUM((s.SMimeMailsSigned + s.SMimeMailsEncrypted + s.SMimeMailsDecrypted + s.SMimeMailsValidated + s.PgpMailsSigned + s.PgpMailsEncrypted + s.PgpMailsDecrypted + s.PgpMailsValidated + s.PdfMailsSent)) = 0 THEN 0 ELSE 1 END AS [Encryption], 6 | CASE WHEN SUM(s.MailsWithDisclaimer) = 0 THEN 0 ELSE 1 END AS Disclaimer, 7 | CASE WHEN SUM(s.MailsWithLargeFiles) = 0 THEN 0 ELSE 1 END AS LargeFiles, 8 | CASE WHEN SUM(s.PdfMailsSent) = 0 THEN 0 ELSE 1 END AS PdfMailsSent, 9 | CASE WHEN SUM(s.SMimeMailsSigned) = 0 THEN 0 ELSE 1 END AS SMimeMailsSigned, 10 | CASE WHEN SUM(s.SMimeMailsEncrypted) = 0 THEN 0 ELSE 1 END AS SMimeMailsEncrypted, 11 | CASE WHEN SUM(s.SMimeMailsValidated) = 0 THEN 0 ELSE 1 END AS SMimeMailsValidated, 12 | CASE WHEN SUM(s.SMimeMailsDecrypted) = 0 THEN 0 ELSE 1 END AS SMimeMailsDecrypted, 13 | CASE WHEN SUM(s.PgpMailsSigned) = 0 THEN 0 ELSE 1 END AS PgpMailsSigned, 14 | CASE WHEN SUM(s.PgpMailsEncrypted) = 0 THEN 0 ELSE 1 END AS PgpMailsEncrypted, 15 | CASE WHEN SUM(s.PgpMailsValidated) = 0 THEN 0 ELSE 1 END AS PgpMailsValidated, 16 | CASE WHEN SUM(s.PgpMailsDecrypted) = 0 THEN 0 ELSE 1 END AS PgpMailsDecrypted, 17 | SUM(CASE WHEN DATEDIFF(d, s.Date,GetDate()) > 30 THEN 0 ELSE s.FilesUploadedToSandbox END) AS FilesUploadedToSandbox 18 | FROM MessageTracking.UserAndDomainStatistic AS s 19 | LEFT OUTER JOIN Usermanagement.MailAddress AS ma ON ma.MailAddress = s.Address 20 | LEFT OUTER JOIN Usermanagement.[User] AS u ON u.Id = ma.UserId 21 | WHERE(s.Date > DATEADD(d, - 90, GETDATE())) 22 | GROUP BY COALESCE (u.Displayname, s.Address) 23 | ) 24 | SELECT 25 | DisplayName, 26 | Protection, 27 | [Encryption], 28 | Disclaimer, 29 | LargeFiles, 30 | FilesUploadedToSandbox, 31 | PdfMailsSent, 32 | SMimeMailsSigned, 33 | SMimeMailsEncrypted, 34 | SMimeMailsValidated, 35 | SMimeMailsDecrypted, 36 | PgpMailsSigned, 37 | PgpMailsEncrypted, 38 | PgpMailsValidated, 39 | PgpMailsDecrypted 40 | FROM Query 41 | WHERE (Protection <> 0) 42 | OR ([Encryption] <> 0) 43 | OR (Disclaimer <> 0) 44 | OR (LargeFiles <> 0) 45 | OR (FilesUploadedToSandbox <> 0) 46 | -------------------------------------------------------------------------------- /Get-NspLicenseReport_(Database)/LicenseUsageDomains_v13.sql: -------------------------------------------------------------------------------- 1 | WITH Query AS ( 2 | SELECT 3 | s.Domain, 4 | COALESCE (u.Displayname, s.Address) AS DisplayName, 5 | CASE WHEN SUM(s.MailsSent) = 0 THEN 0 ELSE 1 END AS Protection, 6 | CASE WHEN SUM((s.SMimeMailsSigned + s.SMimeMailsEncrypted + s.SMimeMailsDecrypted + s.SMimeMailsValidated + s.PgpMailsSigned + s.PgpMailsEncrypted + s.PgpMailsDecrypted + s.PgpMailsValidated + s.PdfMailsSent)) = 0 THEN 0 ELSE 1 END AS [Encryption], 7 | CASE WHEN SUM(s.MailsWithDisclaimer) = 0 THEN 0 ELSE 1 END AS Disclaimer, 8 | CASE WHEN SUM(s.MailsWithLargeFiles) = 0 THEN 0 ELSE 1 END AS LargeFiles, 9 | CASE WHEN SUM(s.PdfMailsSent) = 0 THEN 0 ELSE 1 END AS PdfMailsSent, 10 | CASE WHEN SUM(s.SMimeMailsSigned) = 0 THEN 0 ELSE 1 END AS SMimeMailsSigned, 11 | CASE WHEN SUM(s.SMimeMailsEncrypted) = 0 THEN 0 ELSE 1 END AS SMimeMailsEncrypted, 12 | CASE WHEN SUM(s.SMimeMailsValidated) = 0 THEN 0 ELSE 1 END AS SMimeMailsValidated, 13 | CASE WHEN SUM(s.SMimeMailsDecrypted) = 0 THEN 0 ELSE 1 END AS SMimeMailsDecrypted, 14 | CASE WHEN SUM(s.PgpMailsSigned) = 0 THEN 0 ELSE 1 END AS PgpMailsSigned, 15 | CASE WHEN SUM(s.PgpMailsEncrypted) = 0 THEN 0 ELSE 1 END AS PgpMailsEncrypted, 16 | CASE WHEN SUM(s.PgpMailsValidated) = 0 THEN 0 ELSE 1 END AS PgpMailsValidated, 17 | CASE WHEN SUM(s.PgpMailsDecrypted) = 0 THEN 0 ELSE 1 END AS PgpMailsDecrypted, 18 | SUM(CASE WHEN DATEDIFF(d, s.Date,GetDate()) > 30 THEN 0 ELSE s.FilesUploadedToSandbox END) AS FilesUploadedToSandbox 19 | FROM MessageTracking.UserAndDomainStatistic AS s 20 | LEFT OUTER JOIN Usermanagement.MailAddress AS ma ON ma.MailAddress = s.Address 21 | LEFT OUTER JOIN Usermanagement.[User] AS u ON u.Id = ma.UserId 22 | WHERE(s.Date > DATEADD(d, - 90, GETDATE())) 23 | GROUP BY COALESCE (u.Displayname, s.Address), s.Domain 24 | ) 25 | SELECT 26 | Domain, 27 | DisplayName, 28 | Protection, 29 | [Encryption], 30 | Disclaimer, 31 | LargeFiles, 32 | FilesUploadedToSandbox, 33 | PdfMailsSent, 34 | SMimeMailsSigned, 35 | SMimeMailsEncrypted, 36 | SMimeMailsValidated, 37 | SMimeMailsDecrypted, 38 | PgpMailsSigned, 39 | PgpMailsEncrypted, 40 | PgpMailsValidated, 41 | PgpMailsDecrypted 42 | FROM Query 43 | WHERE (Protection <> 0) 44 | OR ([Encryption] <> 0) 45 | OR (Disclaimer <> 0) 46 | OR (LargeFiles <> 0) 47 | OR (FilesUploadedToSandbox <> 0) 48 | -------------------------------------------------------------------------------- /Get-RejectionReport (Database)/README.md: -------------------------------------------------------------------------------- 1 | # Get-RejectionReport.ps1 2 | 3 | Sends a report to the specified E-Mail address which contains the following information: 4 | 5 | - Total count of processed emails. 6 | - Total count of sent emails. 7 | - Total count of received emails. 8 | - Total count of rejected emails. 9 | - Total count of rejected emails for each Filter and Action. 10 | - Total count of mails to unknown 11 | 12 | This version accesses the NoSpamProxy database directly and is much faster than the other version. The drawback is that most NoSpamProxy installations do not allow remote access to the Database so this script needs to be run locally on the Intranet Role. 13 | 14 | ## Usage 15 | 16 | Download the whole folder (including the SQL scripts) and then run the following command: 17 | 18 | ```ps 19 | Get-RejectionReport -SMTPHost -ReportRecipient -ReportSender [-ReportSubject] [-NumberOfDaysToReport]` 20 | ``` 21 | 22 | - **SMTPHost**: Mandatory. Specifies the SMTP Host which will be used to send the email. 23 | - **ReportRecipient**: Mandatory. Specifies the Recipient of the email. 24 | - **ReportSender**: Mandatory. Specifies the Sender of the email. 25 | - **ReportSubject**: Optional. Specifies the Subject of the email. Default value is "Auswertung". 26 | - **NumberOfDaysToReport**: Optional. Specifies the Number of days to report. Default value is "7". 27 | - **SqlServer**: Optional. The name of the Database server (including instance name, if any). Defaults to (local)\NoSpamProxyDB. 28 | - **Database**: Optional. Name the Database to query. Defaults to "NoSpamProxyAddressSynchronization". 29 | - **Credential**: Optional. Username and password for the SQL authentication on the database server. If not set, Integrated authentication is used, which is the default. 30 | - **TreatUnknownAsSpam**: Optional. When true, mails to unknown recipients are treatet as spam mails. Defaults to `$true`. 31 | - **TopAddressesCount**: Optional. How many Addresses to include in the top Senders/Recipients/Spammers. Defaults to 10 32 | - **ExcludeFromTopAddresses**: Optional. Specify addresses to ignore when evaluating top Senders/Recipients. Useful for dropping obvious addresses from the list to get a more informative statistic 33 | 34 | 35 | ## Example 36 | 37 | ```ps 38 | .\Get-RejectionReport.ps1 -SMTPHost mail.example.com -ReportRecipient admin@example.com' -ReportSender "NoSpamProxy Report Sender " 39 | ``` 40 | 41 | ## Supported NoSpamProxy Versions 42 | 43 | This Script works for NoSpamProxy version 12.x and higher. 44 | -------------------------------------------------------------------------------- /Get-NspLicenseReport_(Database)/LicenseUsageUsers_v14.sql: -------------------------------------------------------------------------------- 1 | declare @tenantId int = '{0}'; 2 | WITH Query AS ( 3 | SELECT 4 | COALESCE (u.Displayname, s.Address) AS DisplayName, 5 | CASE WHEN SUM(s.MailsSent) = 0 THEN 0 ELSE 1 END AS Protection, 6 | CASE WHEN SUM((s.SMimeMailsSigned + s.SMimeMailsEncrypted + s.SMimeMailsDecrypted + s.PgpMailsSigned + s.PgpMailsEncrypted + s.PgpMailsDecrypted + s.PdfMailsSent)) = 0 THEN 0 ELSE 1 END AS [Encryption], 7 | CASE WHEN SUM(s.MailsWithDisclaimer) = 0 THEN 0 ELSE 1 END AS Disclaimer, 8 | CASE WHEN SUM(s.MailsWithLargeFiles) = 0 THEN 0 ELSE 1 END AS LargeFiles, 9 | CASE WHEN SUM(s.PdfMailsSent) = 0 THEN 0 ELSE 1 END AS PdfMailsSent, 10 | CASE WHEN SUM(s.SMimeMailsSigned) = 0 THEN 0 ELSE 1 END AS SMimeMailsSigned, 11 | CASE WHEN SUM(s.SMimeMailsEncrypted) = 0 THEN 0 ELSE 1 END AS SMimeMailsEncrypted, 12 | CASE WHEN SUM(s.SMimeMailsValidated) = 0 THEN 0 ELSE 1 END AS SMimeMailsValidated, 13 | CASE WHEN SUM(s.SMimeMailsDecrypted) = 0 THEN 0 ELSE 1 END AS SMimeMailsDecrypted, 14 | CASE WHEN SUM(s.PgpMailsSigned) = 0 THEN 0 ELSE 1 END AS PgpMailsSigned, 15 | CASE WHEN SUM(s.PgpMailsEncrypted) = 0 THEN 0 ELSE 1 END AS PgpMailsEncrypted, 16 | CASE WHEN SUM(s.PgpMailsValidated) = 0 THEN 0 ELSE 1 END AS PgpMailsValidated, 17 | CASE WHEN SUM(s.PgpMailsDecrypted) = 0 THEN 0 ELSE 1 END AS PgpMailsDecrypted, 18 | SUM(CASE WHEN DATEDIFF(d, s.Date,GetDate()) > 30 THEN 0 ELSE s.FilesUploadedToSandbox END) AS FilesUploadedToSandbox 19 | FROM MessageTracking.UserAndDomainStatistic AS s 20 | LEFT OUTER JOIN Configuration.OwnedDomain AS od ON s.Domain = od.Name 21 | AND s.TenantId = od.TenantId 22 | LEFT OUTER JOIN Usermanagement.LocalAddress AS la ON la.Address = s.Address 23 | AND la.TenantId = s.TenantId 24 | LEFT OUTER JOIN Usermanagement.[User] AS u ON u.Id = la.UserId 25 | AND u.TenantId = la.TenantId 26 | WHERE (s.Date > DATEADD(d, - 90, GETDATE()) AND s.TenantId = @tenantId) 27 | GROUP BY COALESCE (u.Displayname, s.Address) 28 | ) 29 | SELECT 30 | DisplayName, 31 | Protection, 32 | [Encryption], 33 | Disclaimer, 34 | LargeFiles, 35 | FilesUploadedToSandbox, 36 | PdfMailsSent, 37 | SMimeMailsSigned, 38 | SMimeMailsEncrypted, 39 | SMimeMailsValidated, 40 | SMimeMailsDecrypted, 41 | PgpMailsSigned, 42 | PgpMailsEncrypted, 43 | PgpMailsValidated, 44 | PgpMailsDecrypted 45 | FROM Query 46 | WHERE (Protection <> 0) 47 | OR ([Encryption] <> 0) 48 | OR (Disclaimer <> 0) 49 | OR (LargeFiles <> 0) 50 | OR (FilesUploadedToSandbox <> 0) 51 | -------------------------------------------------------------------------------- /Get-NspLicenseReport_(Database)/LicenseUsageDomains_v14.sql: -------------------------------------------------------------------------------- 1 | declare @tenantId int = '{0}'; 2 | WITH Query AS ( 3 | SELECT 4 | s.Domain, 5 | COALESCE (u.Displayname, s.Address) AS DisplayName, 6 | CASE WHEN SUM(s.MailsSent) = 0 THEN 0 ELSE 1 END AS Protection, 7 | CASE WHEN SUM((s.SMimeMailsSigned + s.SMimeMailsEncrypted + s.SMimeMailsDecrypted + s.PgpMailsSigned + s.PgpMailsEncrypted + s.PgpMailsDecrypted + s.PdfMailsSent)) = 0 THEN 0 ELSE 1 END AS [Encryption], 8 | CASE WHEN SUM(s.MailsWithDisclaimer) = 0 THEN 0 ELSE 1 END AS Disclaimer, 9 | CASE WHEN SUM(s.MailsWithLargeFiles) = 0 THEN 0 ELSE 1 END AS LargeFiles, 10 | CASE WHEN SUM(s.PdfMailsSent) = 0 THEN 0 ELSE 1 END AS PdfMailsSent, 11 | CASE WHEN SUM(s.SMimeMailsSigned) = 0 THEN 0 ELSE 1 END AS SMimeMailsSigned, 12 | CASE WHEN SUM(s.SMimeMailsEncrypted) = 0 THEN 0 ELSE 1 END AS SMimeMailsEncrypted, 13 | CASE WHEN SUM(s.SMimeMailsValidated) = 0 THEN 0 ELSE 1 END AS SMimeMailsValidated, 14 | CASE WHEN SUM(s.SMimeMailsDecrypted) = 0 THEN 0 ELSE 1 END AS SMimeMailsDecrypted, 15 | CASE WHEN SUM(s.PgpMailsSigned) = 0 THEN 0 ELSE 1 END AS PgpMailsSigned, 16 | CASE WHEN SUM(s.PgpMailsEncrypted) = 0 THEN 0 ELSE 1 END AS PgpMailsEncrypted, 17 | CASE WHEN SUM(s.PgpMailsValidated) = 0 THEN 0 ELSE 1 END AS PgpMailsValidated, 18 | CASE WHEN SUM(s.PgpMailsDecrypted) = 0 THEN 0 ELSE 1 END AS PgpMailsDecrypted, 19 | SUM(CASE WHEN DATEDIFF(d, s.Date,GetDate()) > 30 THEN 0 ELSE s.FilesUploadedToSandbox END) AS FilesUploadedToSandbox 20 | FROM MessageTracking.UserAndDomainStatistic AS s 21 | LEFT OUTER JOIN Configuration.OwnedDomain AS od ON s.Domain = od.Name 22 | AND s.TenantId = od.TenantId 23 | LEFT OUTER JOIN Usermanagement.LocalAddress AS la ON la.Address = s.Address 24 | AND la.TenantId = s.TenantId 25 | LEFT OUTER JOIN Usermanagement.[User] AS u ON u.Id = la.UserId 26 | AND u.TenantId = la.TenantId 27 | WHERE (s.Date > DATEADD(d, - 90, GETDATE()) AND s.TenantId = @tenantId) 28 | GROUP BY COALESCE (u.Displayname, s.Address), s.Domain 29 | ) 30 | SELECT 31 | Domain, 32 | DisplayName, 33 | Protection, 34 | [Encryption], 35 | Disclaimer, 36 | LargeFiles, 37 | FilesUploadedToSandbox, 38 | PdfMailsSent, 39 | SMimeMailsSigned, 40 | SMimeMailsEncrypted, 41 | SMimeMailsValidated, 42 | SMimeMailsDecrypted, 43 | PgpMailsSigned, 44 | PgpMailsEncrypted, 45 | PgpMailsValidated, 46 | PgpMailsDecrypted 47 | FROM Query 48 | WHERE (Protection <> 0) 49 | OR ([Encryption] <> 0) 50 | OR (Disclaimer <> 0) 51 | OR (LargeFiles <> 0) 52 | OR (FilesUploadedToSandbox <> 0) 53 | -------------------------------------------------------------------------------- /Get-NspLicenseReport/Get-NspLicenseReport.ps1: -------------------------------------------------------------------------------- 1 | param ( 2 | [Parameter(Mandatory=$true)][string] $ExportFilePath, 3 | # only needed for v14 with enabled provider mode 4 | [Parameter(Mandatory=$false)][string] $TenantPrimaryDomain 5 | ) 6 | $minver = [Version]4.0.0; 7 | if ($PSVersionTable.PSVersion -gt $minver) 8 | { 9 | $nspVersion = (Get-ItemProperty -Path HKLM:\SOFTWARE\NoSpamProxy\Components -ErrorAction SilentlyContinue).'Intranet Role' 10 | if ($nspVersion -gt '14.0') { 11 | try { 12 | Connect-Nsp -IgnoreServerCertificateErrors -ErrorAction Stop 13 | } catch { 14 | $e = $_ 15 | Write-Warning "Not possible to connect with the NoSpamProxy. Please check the error message below." 16 | $e |Format-List * -Force 17 | EXIT 18 | } 19 | if ($(Get-NspIsProviderModeEnabled) -eq $true) { 20 | if ($null -eq $TenantPrimaryDomain -OR $TenantPrimaryDomain -eq "") { 21 | Write-Host "Please provide a TenantPrimaryDomain to run this script with NoSpamProxy v14 in provider mode." 22 | EXIT 23 | } else { 24 | # NSP v14 has a new authentication mechanism, Connect-Nsp is required to authenticate properly 25 | # -IgnoreServerCertificateErrors allows the usage of self-signed certificates 26 | Connect-Nsp -IgnoreServerCertificateErrors -PrimaryDomain $TenantPrimaryDomain 27 | } 28 | } 29 | } 30 | $features = Get-nspfeatureusage; 31 | $protcounter = 0; 32 | $protarray = @(); 33 | $enccounter = 0; 34 | $encarray = @(); 35 | $lfcounter = 0; 36 | $lfarray = @(); 37 | $disccounter = 0; 38 | $discarray = @(); 39 | $sandboxcounter = 0; 40 | $sandboxarray = @(); 41 | foreach ($user in $features){ 42 | if ($user.Protection -gt 0) 43 | { 44 | $protcounter+=1; 45 | $protarray+=$user.DisplayName; 46 | } 47 | if ($user.Encryption -gt 0) 48 | { 49 | $enccounter+=1; 50 | $encarray+=$user.DisplayName; 51 | } 52 | if ($user.LargeFiles -gt 0) 53 | { 54 | $lfcounter+=1; 55 | $lfarray+=$user.DisplayName; 56 | } 57 | if ($user.Disclaimer -gt 0) 58 | { 59 | $disccounter+=1; 60 | $discarray+=$user.DisplayName; 61 | } 62 | if ($user.FilesUploadedToSandbox -gt 0) 63 | { 64 | $sandboxcounter+=$user.FilesUploadedToSandbox; 65 | $sandboxarray+=$user.DisplayName + " - " + $user.FilesUploadedToSandbox + " Uploaded File(s)"; 66 | } 67 | } 68 | # the $false prevents UTF8 with BOM 69 | $encoding = New-Object System.Text.UTF8Encoding $false 70 | $stream = New-Object System.IO.StreamWriter $ExportFilePath, $false, $encoding 71 | $stream.WriteLine("Feature-Usage:") 72 | $stream.Write("`r`n") 73 | $stream.WriteLine("Protection: " + $protcounter + " User") 74 | $stream.WriteLine("-----------------------------") 75 | $stream.WriteLine(($protarray | Out-String)) 76 | $stream.WriteLine("`r`n`r`n") 77 | $stream.WriteLine("Encryption: " + $enccounter + " User") 78 | $stream.WriteLine("-----------------------------") 79 | $stream.WriteLine(($encarray | Out-String)) 80 | $stream.WriteLine("`r`n`r`n") 81 | $stream.WriteLine("LargeFiles: " + $lfcounter + " User") 82 | $stream.WriteLine("-----------------------------") 83 | $stream.WriteLine(($lfarray | Out-String)) 84 | $stream.WriteLine("`r`n`r`n") 85 | $stream.WriteLine("Disclaimer: " + $disccounter + " User") 86 | $stream.WriteLine("-----------------------------") 87 | $stream.WriteLine(($discarray | Out-String)) 88 | $stream.WriteLine("`r`n`r`n") 89 | $stream.WriteLine("Sandbox: " + $sandboxcounter + " Uploaded Files") 90 | $stream.WriteLine("-----------------------------") 91 | $stream.WriteLine(($sandboxarray | Out-String)) 92 | $stream.Close() 93 | } 94 | else 95 | { 96 | Write-Host "Eror: PowerShell version is to old. Please Update PowrShell to version 4.0.0" 97 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Reports 2 | 3 | This repository contains PowerShell Scripts to create advanced reports about your NoSpamProxy installation. 4 | 5 | ## Get-RejectionReport 6 | 7 | This report displays information about all rejected e-mails and which filters and actions were involved. Use this version for NoSpamProxy 12.x and higher. 8 | 9 | Currently, there are three versions of this script: 10 | 11 | * [NoSpamProxy 12.x and later, access via Database](Get-RejectionReport%20(Database)) 12 | * [NoSpamProxy 12.x and later, access via WebServices](Get-RejectionReport%20(WebServices)) 13 | * [NoSpamProxy 11.x](11.x/Get-RejectionReport) 14 | 15 | ## Send-ReporttoUserswithAllBlockedEmails 16 | 17 | Sends a report to every E-Mail address that contains all permanently blocked E-Mails in a specific period of time. 18 | 19 | Currently, there are two version of this script: 20 | 21 | * [NoSpamProxy 12.x and later](Send-ReporttoUserswithBlockedEmails) 22 | * [NoSpamProxy 11.x](11.x/Send-ReporttoUsersWithBlockedEmails) 23 | 24 | ## Send-ReporttoUserswithBlockedEmailsWithAttachment 25 | 26 | Sends a report to every E-Mail address that contains all permanently blocked E-Mails in a specific period of time that have been blocked because of an attachment. 27 | 28 | * [NoSpamProxy 12.x and later](Send-ReporttoUserswithBlockedEmailsWithAttachment) 29 | * [NoSpamProxy 11.x](11.x/Send-ReporttoUserswithBlockedEmailsWithAttachment) 30 | 31 | ## [Send-BlockReportToUsers](Send-BlockReportToUsers/Readme.md) 32 | 33 | Rewritten version of "Send-ReporttoUserswithAllBlockedEmails" with enhanced features. 34 | 35 | This script can be used to generate a report about E-Mails which where permanently blocked. 36 | It is possible to filter the results for a specific time duration and sends the report only to specific or all affected users. 37 | This script only uses the NoSpamProxy Powershell Cmdlets to generate the report file. 38 | 39 | 40 | 41 | ## [Get-DmarcReport](https://github.com/noSpamProxy/Reports/tree/master/Get-DMARCReport) 42 | 43 | This report displays information about DMARC Check results for all successful inbound emails. 44 | 45 | Currently, there are two versions of this script: 46 | 47 | * [NoSpamProxy 12.2 and later](Get-DMARCReport) 48 | * [NoSpamProxy 11.x](11.x/Get-DMARCReport) 49 | 50 | ## [Get-EncryptionReport](https://github.com/noSpamProxy/Reports/tree/master/Get-EncryptionReport) 51 | 52 | This script generates a report over the count of encrypted and non encrypted mails. 53 | 54 | ## [Get-ExpiredTLSCertificates](https://github.com/noSpamProxy/Reports/tree/master/get-expiredTLSCertificates) 55 | 56 | This report displays all expired certificates from e-mail servers that NoSpamProxy has sent outbound e-mails to. 57 | 58 | ## [get-certificatesInQuarantine](https://github.com/noSpamProxy/Reports/tree/master/get-certificatesInQuarantine) 59 | 60 | This report displays a list of certificates in the certificate quarantine. 61 | 62 | ## [Get-NspMsgTrackAsCSV](https://github.com/noSpamProxy/Reports/tree/master/Get-NspMsgTrackAsCSV) 63 | 64 | This report exports the message track as CSV file. 65 | 66 | 67 | ## [Get-NspTlsReport](https://github.com/noSpamProxy/Reports/tree/master/Get-NspTlsReport) 68 | 69 | This report generates a HTML which contains an overview of your email communication using TLS. 70 | Requires NSP version 13.0.19147.917 or later. 71 | 72 | ## [Send-BlockReportToUsers](https://github.com/noSpamProxy/Reports/tree/master/Send-BlockReportToUsers) 73 | 74 | This report generates a HTML which contains an overview of your email communication showing all permanently blocked emails. 75 | 76 | ## [Send-EncryptReportToUsers](https://github.com/noSpamProxy/Reports/tree/master/Send-EncryptReportToUsers) 77 | 78 | This report generates a HTML which contains an overview of your email communication showing which emails where encrypted. 79 | 80 | -------------------------------------------------------------------------------- /Get-EncryptionReport/Get-EncryptionReport.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Name: Get-EncryptionReport.ps1 4 | Create report for in- and outbound E-Mails which were encrypted. 5 | Requires NSP version 13.2.20171.1151 or later. 6 | 7 | .DESCRIPTION 8 | This script generates a report over the count of encrypted and non encrypted mails. It seperates results in both directions and timespan (last 30 days and 30 days before that timespan). 9 | 10 | .PARAMETER smtphost 11 | Specifies the Hostname or IP of the mailserver the report will be sent to. 12 | E.g.:mailserver.example.com 13 | 14 | .PARAMETER ReportSender 15 | Specifies the mailaddress used as sender for the report. 16 | E.g.:server@example.com 17 | 18 | .PARAMETER ReportRecipient 19 | Specifies the recipient address for the report. 20 | E.g.: alice@example.com 21 | 22 | .OUTPUTS 23 | Sends an email to the specified recipient with an html-report. 24 | 25 | .NOTES 26 | Version: 1.1.0 27 | Author: Finn Schulte 28 | Creation Date: 2022-06-07 29 | Purpose/Change: added v14 support 30 | 31 | .LINK 32 | https://www.nospamproxy.de 33 | https://forum.nospamproxy.com 34 | https://github.com/noSpamProxy 35 | 36 | .EXAMPLE 37 | .\Get-EncryptionReport.ps1 -smtphost "mailserver.company" -ReportSender "mailgateway@company" -ReportRecipient "admin@company" 38 | #> 39 | 40 | param ( 41 | [Parameter(Mandatory=$true)][string] $smtphost, 42 | [Parameter(Mandatory=$true)][string] $ReportSender, 43 | [Parameter(Mandatory=$true)][string] $ReportRecipient, 44 | # only needed for v14 with enabled provider mode 45 | [Parameter(Mandatory=$false)][string] $TenantPrimaryDomain 46 | ) 47 | 48 | $nspVersion = (Get-ItemProperty -Path HKLM:\SOFTWARE\NoSpamProxy\Components -ErrorAction SilentlyContinue).'Intranet Role' 49 | if ($nspVersion -gt '14.0') { 50 | try { 51 | Connect-Nsp -IgnoreServerCertificateErrors -ErrorAction Stop 52 | } catch { 53 | $e = $_ 54 | Write-Warning "Not possible to connect with the NoSpamProxy. Please check the error message below." 55 | $e |Format-List * -Force 56 | EXIT 57 | } 58 | if ($(Get-NspIsProviderModeEnabled) -eq $true) { 59 | if ($null -eq $TenantPrimaryDomain -OR $TenantPrimaryDomain -eq "") { 60 | Write-Host "Please provide a TenantPrimaryDomain to run this script with NoSpamProxy v14 in provider mode." 61 | EXIT 62 | } else { 63 | # NSP v14 has a new authentication mechanism, Connect-Nsp is required to authenticate properly 64 | # -IgnoreServerCertificateErrors allows the usage of self-signed certificates 65 | Connect-Nsp -IgnoreServerCertificateErrors -PrimaryDomain $TenantPrimaryDomain 66 | } 67 | } 68 | } 69 | 70 | $outboundencrypted = 0 71 | $outboundnonencrypted = 0 72 | $inboundencrypted = 0 73 | $inboundnonencrypted = 0 74 | 75 | for($x=0;$x -lt 30;$x++){ 76 | 77 | $MessageTracks = Get-NspMessageTrack -From (Get-Date).AddDays(-1-$x) -To (Get-Date).AddDays(0-$x) 78 | 79 | Foreach ($MessageTrack in $MessageTracks) 80 | { 81 | if ($MessageTrack.WasReceivedFromRelayServer) 82 | { 83 | if ($MessageTrack.Encrypted -notlike 'None') 84 | { 85 | $outboundencrypted+=1 86 | } 87 | else 88 | { 89 | $outboundnonencrypted+=1 90 | } 91 | } 92 | else 93 | { 94 | if ($MessageTrack.Encrypted -notlike 'None') 95 | { 96 | $inboundencrypted+=1 97 | } 98 | else 99 | { 100 | $inboundnonencrypted+=1 101 | } 102 | } 103 | } 104 | Write-Host "" 105 | } 106 | $global:htmlout = " 107 | 108 | Auswertung über verschlüsselte E-Mails 109 | 110 | 111 | 112 | 113 | " 114 | 115 | $outboundencrypted = 0 116 | $outboundnonencrypted = 0 117 | $inboundencrypted = 0 118 | $inboundnonencrypted = 0 119 | 120 | for($x=0;$x -lt 30;$x++){ 121 | 122 | $MessageTracks = Get-NspMessageTrack -From (Get-Date).AddDays(-31-$x) -To (Get-Date).AddDays(-30-$x) 123 | 124 | Foreach ($MessageTrack in $MessageTracks) 125 | { 126 | if ($MessageTrack.WasReceivedFromRelayServer) 127 | { 128 | if ($MessageTrack.Encrypted -notlike 'None') 129 | { 130 | $outboundencrypted+=1 131 | } 132 | else 133 | { 134 | $outboundnonencrypted+=1 135 | } 136 | } 137 | else 138 | { 139 | if ($MessageTrack.Encrypted -notlike 'None') 140 | { 141 | $inboundencrypted+=1 142 | } 143 | else 144 | { 145 | $inboundnonencrypted+=1 146 | } 147 | } 148 | } 149 | } 150 | $global:htmlout+=" 151 |
ZeitraumEingehendAusgehend
Letzte 30 Tage" + $inboundencrypted + " Mails verschlüsselt
" + $inboundnonencrypted + "Mails unverschlüsselt
" + $outboundencrypted + " Mails verschlüsselt
" + $outboundnonencrypted + "Mails unverschlüsselt
Vorherige 30 Tage" + $inboundencrypted + " Mails verschlüsselt
" + $inboundnonencrypted + "Mails unverschlüsselt
" + $outboundencrypted + " Mails verschlüsselt
" + $outboundnonencrypted + "Mails unverschlüsselt
" 152 | 153 | Write-Host "Report Generated Successfully" 154 | 155 | "Sending report to $ReportRecipient" 156 | 157 | $message= New-Object Net.Mail.MailMessage 158 | $smtp = New-Object Net.Mail.SmtpClient ($smtphost) 159 | $message.From = $ReportSender 160 | $message.To.Add($ReportRecipient) 161 | $message.subject = "NoSpamProxy Verschlüsselungs-Report der letzten " + $Age + " Tage vom " + (Get-Date) 162 | $message.IsBodyHtml = $true 163 | $message.Body = $global:htmlout 164 | $smtp.send($message) 165 | $message.Dispose(); -------------------------------------------------------------------------------- /Get-NspSandboxStatistic/Readme.md: -------------------------------------------------------------------------------- 1 | # Get-NspSandboxStatistic.ps1 2 | Create a Cyren Sandbox statistic for rejected emails. 3 | 4 | ## Usage 5 | 6 | ```ps 7 | Get-NspSandboxStatistic\Get-NspSandboxStatistic.ps1 -FromDate [-ToDate ] [-NspRule ] [-NoMail] [-ReportRecipient ] [-ReportRecipientCSV ] [-ReportSender ] [-ReportSubject ] [-SmtpHost ] [-TenantPrimaryDomain ] [] 8 | ``` 9 | ```ps 10 | Get-NspSandboxStatistic\Get-NspSandboxStatistic.ps1 -NumberOfDaysToReport [-NspRule ] [-NoMail] [-ReportRecipient ] [-ReportRecipientCSV ] [-ReportSender ] [-ReportSubject ] [-SmtpHost ] [-TenantPrimaryDomain ] [] 11 | ``` 12 | ```ps 13 | Get-NspSandboxStatistic\Get-NspSandboxStatistic.ps1 -NumberOfHoursToReport [-NspRule ] [-NoMail] [-ReportRecipient ] [-ReportRecipientCSV ] [-ReportSender ] [-ReportSubject ] [-SmtpHost ] [-TenantPrimaryDomain ] [] 14 | ``` 15 | ```ps 16 | Get-NspSandboxStatistic\Get-NspSandboxStatistic.ps1 -ReportInterval [-NspRule ] [-NoMail] [-ReportRecipient ] [-ReportRecipientCSV ] [-ReportSender ] [-ReportSubject ] [-SmtpHost ] [-TenantPrimaryDomain ] [] 17 | ``` 18 | ```ps 19 | Get-NspSandboxStatistic\Get-NspSandboxStatistic.ps1 -NoTime [-NspRule ] [-NoMail] [-ReportRecipient ] [-ReportRecipientCSV ] [-ReportSender ] [-ReportSubject ] [-SmtpHost ] [-TenantPrimaryDomain ] [] 20 | ``` 21 | 22 | 23 | ## Parameters 24 | ### FromDate 25 | Mandatory if you like to use a timespan. 26 | Specifies the start date for the E-Mail filter. 27 | Please use ISO 8601 date format: "YYYY-MM-DD hh:mm:ss" 28 | E.g.: 29 | "2019-06-05 08:00" or "2019-06-05 20:00:00" 30 | 31 | ### MailRecipientCSV 32 | 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. 33 | 34 | ### NoMail 35 | Does not generate an E-Mail and saves the generated reports to the current execution location. 36 | Ideal for testing or manual script usage. 37 | 38 | ### NoTime 39 | Mandatory if you do not like to specify a time value in any kind of way. 40 | No value needs to be passed here \ is just a single switch. 41 | 42 | ### NspRule 43 | Specify a rule name which is defined in NSP as E-Mail filter. 44 | 45 | ### NumberOfDays 46 | Mandatory if you like to use a number of days for filtering. 47 | Specifies the number of days for which th E-Mails should be filtered. 48 | 49 | ### NumberOfHoursToReport 50 | Mandatory if you like to use a number of hours for filtering. 51 | Specifies the number of hours for which th E-Mails should be filtered. 52 | 53 | ### ReportInterval 54 | Mandatory if you like to use a predefined timespan. 55 | Specifies a predefined timespan. 56 | 57 | Possible values are: 58 | daily, monthly, weekly 59 | 60 | The report will start at 00:00:00 o'clock and ends at 23:59:59 o'clock. 61 | The script call must be a day after the desired report end day. 62 | 63 | ### ReportRecipient 64 | Specifies the E-Mail recipient. It is possible to pass a comma separated list to address multiple recipients. 65 | E.g.: alice@example.com, bob@example.com 66 | 67 | ### ReportRecipientCSV 68 | 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. 69 | 70 | ### ReportSender 71 | **Default:** NoSpamProxy Report Sender \ 72 | Sets the report E-Mail sender address. 73 | 74 | ### ReportSubject 75 | **Default:** NSP Sandbox statistic 76 | Sets the report E-Mail subject. 77 | 78 | ### SmtpHost 79 | Specifies the SMTP host which should be used to send the report E-Mail. 80 | It is possible to use a FQDN or IP address. 81 | 82 | ### TenantPrimaryDomain 83 | Used to login into the desired NoSpamProxy tenant to run this script on. 84 | Only required if NoSpamProxy v14 is used in provider mode. 85 | 86 | ### ToDate 87 | Optional if you like to use a timespan. 88 | Specifies the end date for the E-Mail filter. 89 | Please use ISO 8601 date format: "YYYY-MM-DD hh:mm:ss" 90 | E.g.: 91 | "2019-06-05 08:00" or "2019-06-05 20:00:00" 92 | 93 | ## Outputs 94 | none 95 | 96 | ## Examples 97 | ### Example 1 98 | ```ps 99 | Get-NspSandboxStatistic.ps1 -NoTime -ReportRecipient alice@example.com -ReportSender "NoSpamProxy Report Sender " -ReportSubject "Example Report" -SmtpHost mail.example.com 100 | ``` 101 | 102 | ### EXAMPLE 2 103 | ```ps 104 | Get-NspSandboxStatistic.ps1 -FromDate: "2019-06-05 08:00:00" -ToDate: "2019-06-05 20:00:00" -NoMail 105 | ``` 106 | It is mandatory to specify \. Instead \ is optional. 107 | These parameters can be combined with all other parameters except \, \, \ and \. 108 | 109 | ### EXAMPLE 3 110 | ```ps 111 | Get-NspSandboxStatistic.ps1 -NumberOfDaysToReport 7 -NoMail 112 | ``` 113 | You can combine \ with all other parameters except \, \, \, \ and \. 114 | 115 | ### EXAMPLE 4 116 | ```ps 117 | Get-NspSandboxStatistic.ps1 -NumberOfHoursToReport 12 -NoMail 118 | ``` 119 | You can combine \ with all other parameters except \, \, \, \ and \. 120 | 121 | ### EXAMPLE 5 122 | ```ps 123 | Get-NspSandboxStatistic.ps1 -ReportInterval weekly -NoMail 124 | ``` 125 | You can combine \ with all other parameters except \, \, \, \, \ and \. 126 | 127 | ### EXAMPLE 6 128 | ```ps 129 | Get-NspSandboxStatistic.ps1 -NoTime -NoMail -NspRule "All other inbound mails" 130 | ``` 131 | 132 | ### EXAMPLE 7 133 | ```ps 134 | Get-NspSandboxStatistic.ps1 -NoTime -SmtpHost mail.example.com -ReportRecipientCSV "C:\Users\example\Documents\email-report.csv" 135 | ``` 136 | The CSV have to contain the header "Email" else the mail addresses cannot be read from the file. 137 | It is possible to combine \ with \. 138 | E.g: email-report.csv 139 | User,Email 140 | user1,user1@example.com 141 | user2,user2@example.com -------------------------------------------------------------------------------- /Get-NspLicenseReport_(Database)/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | # Get-NspLicenseReport.ps1 3 | 4 | Generates a report for the usage of each module. 5 | It is possible to generate a user-based report which contains the following information: 6 | 7 | - Total Users who used the module 8 | - List of each user who used the module 9 | 10 | Moreover it is possible to generate a domain-based report which contains the same information like above but separated for each domain. 11 | Be aware of the fact that a user with mulitple domains will be counted multiple times in the domain based report. 12 | 13 | ## Usage 14 | 15 | ```ps 16 | Get-NspLicenseReport.ps1 [-NoMail] [[-ReportFileName] ] [[-ReportRecipient] ] [[-ReportRecipientCSV] ] [[-ReportSender] ] [[-ReportSubject] ] [[-ReportType] ] [[-SmtpHost] ] [[-SqlCredential] ] [[-SqlUsername] ] [[-SqlPasswordFileLocation] ] [[-SqlDatabase] ] [[-SqlInstance] ] [[-SqlServer] ] [-WithEncryptionDetails] [-GDPRconform] [-Minimal] [[-TenantId] ] [-SetLoginPassword] [][-NoMail] [[-ReportFileName] ] [[-ReportRecipient] ] [[-ReportRecipientCSV] ][[-ReportSender] ] [[-ReportSubject] ] [[-ReportType] user-based | domain-based | both] [[-SmtpHost] ] [[-SqlCredential] ] [[-SqlDatabase] ] [[-SqlInstance]] [[-SqlServer] ] [[-TenantId] ] [] 17 | ``` 18 | 19 | ## Parameters 20 | ### GDPRconform 21 | Generates a report with hashed names and e-mail addresses. 22 | 23 | ### Minimal 24 | The output file will only contain the numeric number of used licenses. 25 | 26 | ### NoMail 27 | Does not generate an E-Mail and saves the generated reports to the current execution location. 28 | Ideal for testing or manual script usage. 29 | 30 | ### ReportFileName 31 | **Default:** License_Report 32 | Define a part of the complete file name. 33 | 34 | **user-based:** 35 | C:\Users\example\Documents\2019-05-27_License_Report_per_user.txt 36 | **domain-based:** 37 | C:\Users\example\Documents\2019-05-27_License_Report_example.com.txt 38 | 39 | ### ReportRecipient 40 | Specifies the E-Mail recipient. It is possible to pass a comma separated list to address multiple recipients. 41 | E.g.: alice@example.com, bob@example.com 42 | 43 | ### ReportRecipientCSV 44 | 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. 45 | 46 | ### ReportSender 47 | **Default:** NoSpamProxy Report Sender 48 | Sets the report E-Mail sender address. 49 | 50 | ### ReportSubject 51 | **Default:** NSP License Report 52 | Sets the report E-Mail subject. 53 | 54 | ### ReportType 55 | **Default:** user-based 56 | Sets the type of generated report. 57 | Possible values are: user-based, domain-based, both 58 | 59 | ### SetLoginPassword 60 | Starts an interactive mode to save an entered password into an machine encrypted file. 61 | Be aware that the input is displayed. 62 | 63 | ### SmtpHost 64 | Specifies the SMTP host which should be used to send the report E-Mail. 65 | It is possible to use a FQDN or IP address. 66 | 67 | ### SqlCredential 68 | Sets custom credentials for database access. 69 | By default the authentication is done using current users credentials from memory. 70 | 71 | ### SqlDatabase 72 | **Default:** NoSpamProxyAddressSynchronization 73 | Sets a custom SQl database name which should be accessed. The required database is the one from the intranet-role. 74 | 75 | ### SqlInstance 76 | **Default:** NoSpamProxy 77 | Sets a custom SQL instance name which should be accessed. The required instance must contain the intranet-role database. 78 | 79 | ### SqlPasswordFileLocation 80 | **Default:** "$PSScriptRoot\NspReadSqlPass.bin" 81 | Set the location of the password file. The default is resolved to the current script location. 82 | 83 | ### SqlServer 84 | **Default:** (local) 85 | Sets a custom SQL server which must contains the instance and the database of the intranet-role. 86 | 87 | ### SqlUsername 88 | Set a username which is used for the SQL login. 89 | If this parameter is used an SQL password file needs to be provided or the password needs to be entered manually on runtime. 90 | 91 | ### TenantId 92 | **Default:** 0 93 | Provide the tenant for which a license report should be generated. 94 | 95 | ### WithEncryptionDetails 96 | Enables a detailed report for the encryption module. 97 | The output will be splittet into SMIME/PGP encryption and decryption and PDF Encryption. 98 | 99 | ## Outputs 100 | Report is temporary stored under %TEMP% if the report is send via by E-Mail. 101 | If the parameter is used the files will be saved at the current location of the executing user. 102 | 103 | ## Examples 104 | 105 | ### Example 1 106 | ```ps 107 | Get-NspLicenseReport.ps1 -ReportRecipient alice@example.com -ReportSender nospamproxy@example.com -ReportSubject "Example Report" -SmtpHost mail.example.com 108 | ``` 109 | 110 | ### Example 2 111 | ```ps 112 | Get-NspLicenseReport.ps1 -ReportRecipient alice@example.com -ReportSender nospamproxy@example.com -ReportSubject "Example Report" -SmtpHost mail.example.com -ReportRecipientCSV "C:\Users\example\Documents\email-recipient.csv" 113 | ``` 114 | The CSV have to contain the header "Email" else the mail addresses cannot be read from the file. 115 | 116 | E.g: email-recipient.csv 117 | User,Email 118 | user1,user1@example.com 119 | user2,user2@example.com 120 | 121 | The "User" header is not necessary. 122 | 123 | ### Example 3 124 | ```ps 125 | Get-NspLicenseReport.ps1 -NoMail -ReportType both 126 | ``` 127 | Generates a user-based and a domain-based report which are saved at the current location of execution, here: ".\" 128 | 129 | ### Example 4 130 | ```ps 131 | Get-NspLicenseReport.ps1 -NoMail -SqlServer sql.example.com -SqlInstance NSPIntranetRole -SqlDatabase NSPIntranet -SqlCredential $Credentials 132 | ``` 133 | This generates a user-based report. Therefore the script connects to the SQL Server "sql.example.com" and accesses the SQL instance "NSPIntranetRole" which contains the "NSPIntranet" database. 134 | The passed varaible "$Credentials" contains the desired user credentials. (e.x. $Credentials = Get-Credentials) 135 | ### Example 5 136 | ```ps 137 | Get-NspLicenseReport.ps1 -NoMail -SqlInstance "" 138 | ``` 139 | Use the above instance name "" if you try to access the default SQL instance. 140 | If there is a connection problem and the NSP configuration shows an empty instance for the intranet-role under "Configuration -> NoSpamProxy components" than this instance example should work. 141 | ### Example 6 142 | ```ps 143 | Get-NspLicenseReport.ps1 -NoMail -SqlInstance "" -TenantId 42 144 | ``` 145 | NoSpamProxy v14 provides a provider mode which allows the usage of multiple tenants. 146 | To generate a report for a specific tenant it is necessary to provide the desired tenant id. 147 | -------------------------------------------------------------------------------- /Get-NspTlsReport/Readme.md: -------------------------------------------------------------------------------- 1 | # Get-NspTlsReport 2 | 3 | Requires NSP version 13.0.19147.917 or later. 4 | 5 | Creates a HTML report containing the following data: 6 | 7 | - number of all inbound connections 8 | - number of all inbound connections without TLS 9 | - percent number of all inbound connections without TLS 10 | - number of all outbound connections 11 | - number of all outbound connections without TLS 12 | - percent number of all outbound connections without TLS 13 | - all external addresses which send an email without TLS 14 | - all external addresses which are addresses from internal without TLS 15 | 16 | The output can be changed by various filters, see parameters section. 17 | 18 | ## Usage 19 | 20 | ```ps 21 | Get-NspTlsReport.ps1 -FromDate [-ToDate ] [-Status ] [-NspRule ] [-NoMail] [-ReportFileName ] [-ReportRecipient ] [-ReportRecipientCSV ] [-ReportSender ] [-ReportSubject ] [-SmtpHost ] [-TenantPrimaryDomain ] [] 22 | ``` 23 | ```ps 24 | Get-NspTlsReport.ps1 -NumberOfDaysToReport [-Status ] [-NspRule ] [-NoMail] [-ReportFileName ] [-ReportRecipient ] [-ReportRecipientCSV ] [-ReportSender ] [-ReportSubject ] [-SmtpHost ] [-TenantPrimaryDomain ] [] 25 | ``` 26 | ```ps 27 | Get-NspTlsReport.ps1 -NumberOfHoursToReport [-Status ] [-NspRule ] [-NoMail] [-ReportFileName ] [-ReportRecipient ] [-ReportRecipientCSV ] [-ReportSender ] [-ReportSubject ] [-SmtpHost ] [-TenantPrimaryDomain ] [] 28 | ``` 29 | ```ps 30 | Get-NspTlsReport.ps1 -ReportInterval [-Status ] [-NspRule ] [-NoMail] [-ReportFileName ] [-ReportRecipient ] [-ReportRecipientCSV ] [-ReportSender ] [-ReportSubject ] [-SmtpHost ] [-TenantPrimaryDomain ] [] 31 | ``` 32 | ```ps 33 | Get-NspTlsReport.ps1 -NoTime [-Status ] [-NspRule ] [-NoMail] [-ReportFileName ] [-ReportRecipient ] [-ReportRecipientCSV ] [-ReportSender ] [-ReportSubject ] [-SmtpHost ] [-TenantPrimaryDomain ] [] 34 | ``` 35 | 36 | 37 | ## Parameters 38 | ### FromDate 39 | Mandatory if you like to use a timespan. 40 | Specifies the start date for the E-Mail filter. 41 | Please use ISO 8601 date format: "YYYY-MM-DD hh:mm:ss" 42 | E.g.: 43 | "2019-06-05 08:00:00" 44 | 45 | ### NoMail 46 | Does not generate an E-Mail and saves the generated reports to the current execution location. 47 | Ideal for testing or manual script usage. 48 | 49 | ### NoTime 50 | Mandatory if you do not like to specify a time value in any kind of way. 51 | No value needs to be passed here \ is just a single switch. 52 | 53 | ### NspRule 54 | Specify a rule name which is defined in NSP as E-Mail filter. 55 | 56 | ### NumberOfDays 57 | Mandatory if you like to use a number of days for filtering. 58 | Specifies the number of days for which th E-Mails should be filtered. 59 | 60 | ### NumberOfHoursToReport 61 | Mandatory if you like to use a number of hours for filtering. 62 | Specifies the number of hours for which th E-Mails should be filtered. 63 | 64 | ### ReportFileName 65 | **Default:** TLSReport 66 | Define a part of the complete file name. 67 | 68 | E.g.: 2019-06-05-msgTrackReport.csv 69 | 70 | ### ReportInterval 71 | Mandatory if you like to use a predefined timespan. 72 | Specifies a predefined timespan. 73 | 74 | Possible values are: 75 | daily, monthly, weekly 76 | 77 | The report will start at 00:00:00 o'clock and ends at 23:59:59 o'clock. 78 | The script call must be a day after the desired report end day. 79 | 80 | ### ReportRecipient 81 | Specifies the E-Mail recipient. It is possible to pass a comma separated list to address multiple recipients. 82 | E.g.: alice@example.com, bob@example.com 83 | 84 | ### ReportRecipientCSV 85 | 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. 86 | 87 | ### ReportSender 88 | **Default:** NoSpamProxy Report Sender \ 89 | Sets the report E-Mail sender address. 90 | 91 | ### ReportSubject 92 | **Default:** NSP TLS Report 93 | Sets the report E-Mail subject. 94 | 95 | ### SmtpHost 96 | Specifies the SMTP host which should be used to send the report E-Mail. 97 | It is possible to use a FQDN or IP address. 98 | 99 | ### Status 100 | Specifies a filter to get only E-Mails which are matching the defined state. 101 | 102 | Possible values are: 103 | None | Success | DispatcherError | TemporarilyBlocked | PermanentlyBlocked | PartialSuccess | DeliveryPending | Suppressed | DuplicateDrop | PutOnHold | All 104 | 105 | ### TenantPrimaryDomain 106 | Used to login into the desired NoSpamProxy tenant to run this script on. 107 | Only required if NoSpamProxy v14 is used in provider mode. 108 | 109 | ### ToDate 110 | Optional if you like to use a timespan. 111 | Specifies the end date for the E-Mail filter. 112 | Please use ISO 8601 date format: "YYYY-MM-DD hh:mm:ss" 113 | E.g.: 114 | "2019.06-05 08:00:00" 115 | 116 | ## Outputs 117 | Report is stored under %TEMP% if the report is send via E-Mail the file will be removed. 118 | 119 | 120 | ## Examples 121 | ### Example 1 122 | ```ps 123 | Get-NspTlsReport -NoTime -Status "Success" -ReportFileName "Example-Report" -ReportRecipient alice@example.com -ReportSender "NoSpamProxy Report Sender \" -ReportSubject "Example Report" -SmtpHost mail.example.com 124 | ``` 125 | 126 | ### EXAMPLE 2 127 | ```ps 128 | Get-NspTlsReport -FromDate: "2019-06-05 08:00:00" -ToDate: "2019-06-05 20:00:00" -NoMail 129 | ``` 130 | It is mandatory to specify \. Instead \ is optional. 131 | These parameters can be combined with all other parameters except \, \, \ and \. 132 | 133 | ### EXAMPLE 3 134 | ```ps 135 | Get-NspTlsReport -NumberOfDaysToReport 7 -NoMail 136 | ``` 137 | You can combine \ with all other parameters except \, \, \, \ and \. 138 | 139 | ### EXAMPLE 4 140 | ```ps 141 | Get-NspTlsReport -NumberOfHoursToReport 12 -NoMail 142 | ``` 143 | You can combine \ with all other parameters except \, \, \, \ and \. 144 | 145 | ### EXAMPLE 5 146 | ```ps 147 | Get-NspTlsReport -ReportInterval weekly -NoMail 148 | ``` 149 | You can combine \ with all other parameters except \, \, \, \, \ and \. 150 | 151 | ### EXAMPLE 6 152 | ```ps 153 | Get-NspTlsReport -NoTime -NoMail -NspRule "All other inbound mails" 154 | ``` 155 | 156 | ### EXAMPLE 7 157 | ```ps 158 | Get-NspTlsReport -NoTime -SmtpHost mail.example.com -ReportRecipientCSV "C:\Users\example\Documents\email-report.csv" 159 | ``` 160 | The CSV have to contain the header "Email" else the mail addresses cannot be read from the file. 161 | It is possible to combine \ with \. 162 | E.g: email-report.csv 163 | User,Email 164 | user1,user1@example.com 165 | user2,user2@example.com -------------------------------------------------------------------------------- /Send-EncryptReportToUsers/Readme.md: -------------------------------------------------------------------------------- 1 | # Send-EncryptionReportToUsers.ps1 2 | 3 | This script can be used to generate a report about outbound E-Mails and shows if they where encrypted or not. 4 | It is possible to filter the results for a specific time duration and sends the report only to specific or all affected users. 5 | This script only uses the NoSpamProxy Powershell Cmdlets to generate the report file. 6 | 7 | The output contains the following information: 8 | - sent time 9 | - recipient 10 | - subject 11 | - encryption status 12 | 13 | ## Usage 14 | ```ps 15 | Send-EncryptionReportToUsers.ps1 -FromDate [-ToDate ] [-ReportSender ] [-ReportSubject ] [-ReportFileName ] [-SmtpHost ] [-ReportRecipient ] [-ReportRecipientCSV ] [-AdServer ] [-AdPort ] [-AdBaseDN ] [-AdReportGroup ] [-AdUsername ] [-TenantPrimaryDomain ] [] 16 | ``` 17 | ```ps 18 | Send-EncryptionReportToUsers.ps1 -NoTime [-ReportSender ] [-ReportSubject ] [-ReportFileName ] [-SmtpHost ] [-ReportRecipient ] [-ReportRecipientCSV ] [-AdServer ] [-AdPort ] [-AdBaseDN ] [-AdReportGroup ] [-AdUsername ] [-TenantPrimaryDomain ] [] 19 | ``` 20 | ```ps 21 | Send-EncryptionReportToUsers.ps1 -NumberOfDaysToReport [-ReportSender ] [-ReportSubject ] [-ReportFileName ] [-SmtpHost ] [-ReportRecipient ] [-ReportRecipientCSV ] [-AdServer ] [-AdPort ] [-AdBaseDN ] [-AdReportGroup ] [-AdUsername ] [-TenantPrimaryDomain ] [] 22 | ``` 23 | ```ps 24 | Send-EncryptionReportToUsers.ps1 -NumberOfHoursToReport [-ReportSender ] [-ReportSubject ] [-ReportFileName ] [-SmtpHost ] [-ReportRecipient ] [-ReportRecipientCSV ] [-AdServer ] [-AdPort ] [-AdBaseDN ] [-AdReportGroup ] [-AdUsername ] [-TenantPrimaryDomain ] [] 25 | ``` 26 | ```ps 27 | Send-EncryptionReportToUsers.ps1 -ReportInterval [-ReportSender ] [-ReportSubject ] [-ReportFileName ] [-SmtpHost ] [-ReportRecipient ] [-ReportRecipientCSV ] [-AdServer ] [-AdPort ] [-AdBaseDN ] [-AdReportGroup ] [-AdUsername ] [-TenantPrimaryDomain ] [] 28 | ``` 29 | ```ps 30 | Send-EncryptReportToUsers.ps1 -SetAdPassword [-ReportFileName ] [] 31 | ``` 32 | 33 | ## Parameters 34 | ### AdBaseDn 35 | Define the BaseDN for searching a user group in the defined AD. 36 | 37 | ### AdPort 38 | Default: 389 39 | Define a custom port to access the AD. 40 | 41 | ### AdReportGroup 42 | Define the AD user group to search for. 43 | The users in this group will receive a report. 44 | 45 | ### AdServer 46 | Define the hostname, FQDN or IP address of the desired AD. 47 | 48 | ### AdUsername 49 | Define an optional username to authenticate against the AD. 50 | A password have to be set before using . 51 | 52 | ### FromDate 53 | Mandatory if you like to use a timespan. 54 | Specifies the start date for the E-Mail filter. 55 | Please use ISO 8601 date format: "YYYY-MM-DD hh:mm:ss" 56 | E.g.: 57 | "2019-06-05 08:00" or "2019-06-05 20:00:00:00" 58 | 59 | ### MailRecipientCSV 60 | 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. 61 | 62 | ### NoTime 63 | Mandatory if you do not like to specify a time value in any kind of way. 64 | No value needs to be passed here \ is just a single switch. 65 | 66 | ### NspRule 67 | Specify a rule name which is defined in NSP as E-Mail filter. 68 | 69 | ### NumberOfDays 70 | Mandatory if you like to use a number of days for filtering. 71 | Specifies the number of days for which th E-Mails should be filtered. 72 | 73 | ### NumberOfHoursToReport 74 | Mandatory if you like to use a number of hours for filtering. 75 | Specifies the number of hours for which th E-Mails should be filtered. 76 | 77 | ### ReportFileName 78 | **Default:** reject-analysis 79 | Define a part of the complete file name. 80 | 81 | E.g.: 2019-06-05-msgTrackReport.csv 82 | 83 | ### ReportInterval 84 | Mandatory if you like to use a predefined timespan. 85 | Specifies a predefined timespan. 86 | 87 | Possible values are: 88 | daily, monthly, weekly 89 | 90 | The report will start at 00:00:00 o'clock and ends at 23:59:59 o'clock. 91 | The script call must be a day after the desired report end day. 92 | 93 | ### ReportRecipient 94 | Specifies the E-Mail recipient. It is possible to pass a comma separated list to address multiple recipients. 95 | E.g.: alice@example.com, bob@example.com 96 | 97 | ### ReportRecipientCSV 98 | 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. 99 | 100 | ### ReportSender 101 | **Default:** NoSpamProxy Report Sender \ 102 | Sets the report E-Mail sender address. 103 | 104 | ### ReportSubject 105 | **Default:** Auswertung der abgewiesenen E-Mails an Sie 106 | Sets the report E-Mail subject. 107 | 108 | ### SetAdPassword 109 | Set a password to use for authentication against the AD. 110 | The password will be saved as encrypted "NspAdReportingPass.bin" file under %APPDATA%. 111 | 112 | ### SmtpHost 113 | Specifies the SMTP host which should be used to send the report E-Mail. 114 | It is possible to use a FQDN or IP address. 115 | 116 | ### TenantPrimaryDomain 117 | Used to login into the desired NoSpamProxy tenant to run this script on. 118 | Only required if NoSpamProxy v14 is used in provider mode. 119 | 120 | ### ToDate 121 | Optional if you like to use a timespan. 122 | Specifies the end date for the E-Mail filter. 123 | Please use ISO 8601 date format: "YYYY-MM-DD hh:mm:ss" 124 | E.g.: 125 | "2019-06-05 08:00" or "2019-06-05 20:00:00" 126 | 127 | ## Outputs 128 | Report is stored under %TEMP% if the report is send via E-Mail the file will be removed. 129 | 130 | 131 | ## Examples 132 | ### Example 1 133 | ```ps 134 | Send-EncryptionReportToUsers.ps1 -NoTime -ReportFileName "Example-Report" -ReportRecipient alice@example.com -ReportSender "NoSpamProxy Report Sender \" -ReportSubject "Example Report" -SmtpHost mail.example.com 135 | ``` 136 | 137 | ### EXAMPLE 2 138 | ```ps 139 | Send-EncryptionReportToUsers.ps1 -FromDate: "2019-06-05 08:00:00" -ToDate: "2019-06-05 20:00:00" 140 | ``` 141 | It is mandatory to specify \. Instead \ is optional. 142 | These parameters can be combined with all other parameters except \, \, \ and \. 143 | 144 | ### EXAMPLE 3 145 | ```ps 146 | Send-EncryptionReportToUsers.ps1 -NumberOfDaysToReport 7 147 | ``` 148 | You can combine \ with all other parameters except \, \, \, \ and \. 149 | 150 | ### EXAMPLE 4 151 | ```ps 152 | Send-EncryptionReportToUsers.ps1 -NumberOfHoursToReport 12 153 | ``` 154 | You can combine \ with all other parameters except \, \, \, \ and \. 155 | 156 | ### EXAMPLE 5 157 | ```ps 158 | Send-EncryptionReportToUsers.ps1 -ReportInterval weekly 159 | ``` 160 | You can combine \ with all other parameters except \, \, \, \, \ and \. 161 | 162 | ### EXAMPLE 6 163 | ```ps 164 | Send-EncryptionReportToUsers.ps1 -NoTime -NspRule "All other inbound mails" 165 | ``` 166 | 167 | ### EXAMPLE 7 168 | ```ps 169 | Send-EncryptionReportToUsers.ps1 -NoTime -SmtpHost mail.example.com -ReportRecipientCSV "C:\Users\example\Documents\email-report.csv" 170 | ``` 171 | The CSV have to contain the header "Email" else the mail addresses cannot be read from the file. 172 | It is possible to combine \ with \. 173 | E.g: email-report.csv 174 | User,Email 175 | user1,user1@example.com 176 | user2,user2@example.com 177 | 178 | ### EXAMPLE 8 179 | ```ps 180 | Send-EncryptionReportToUsers.ps1 -NoTime -AdServer ad.example.com -AdBaseDN "DC=example,DC=com" -AdReportGroup "MyReportGroup" 181 | ``` 182 | Connect to AD as anonymous. 183 | 184 | ### EXAMPLE 9 185 | ```ps 186 | Send-EncryptionReportToUsers.ps1 -NoTime -AdServer ad.example.com -AdBaseDN "DC=example,DC=com" -AdReportGroup "MyReportGroup" -AdUsername Administrator 187 | ``` 188 | Connect to AD as Administrator, password needs to be set using .\Send-EncryptionReportToUsers.ps1 -SetAdPassword 189 | 190 | ### EXAMPLE 10 191 | ```ps 192 | Send-EncryptionReportToUsers.ps1 -SetAdPassword 193 | ``` 194 | Will wait for a user input. The input is shown in plain text! -------------------------------------------------------------------------------- /Get-NspMsgTrackAsCSV/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | # Get-NspMsgTrackAsCSV.ps1 3 | 4 | Exports filtered message tracks to a CSV containing the following information: 5 | 6 | - sent time 7 | - subject 8 | - status 9 | - sender 10 | - recipient 11 | - signed 12 | - encrypted 13 | - message ID 14 | 15 | 16 | ## Usage 17 | 18 | ```ps 19 | Get-NspMsgTrackAsCSV.ps1 -FromDate [-ToDate ] [-Status ] [-NspRule ] [-MailRecipientCSV ] [-NoMail] [-ReportFileName ] [-ReportRecipient ] [-ReportRecipientCSV ] [-ReportSender ] [-ReportSubject ] [-SmtpHost ] [-TenantPrimaryDomain ] [-TransactionId ] [-IpAddress ] [-MailSubject ] [-MessageId ] [-MinScl ] [-MaxScl ] [-Direction ] [-EmailAddress1 ] [-EmailAddress2 ] [] 20 | ``` 21 | ```ps 22 | Get-NspMsgTrackAsCSV.ps1 -NumberOfDaysToReport [-Status ] [-NspRule ] [-MailRecipientCSV ] [-NoMail] [-ReportFileName ] [-ReportRecipient ] [-ReportRecipientCSV ] [-ReportSender ] [-ReportSubject ] [-SmtpHost ] [-TenantPrimaryDomain ] [-TransactionId ] [-IpAddress ] [-MailSubject ] [-MessageId ] [-MinScl ] [-MaxScl ] [-Direction ] [-EmailAddress1 ] [-EmailAddress2 ] [] 23 | ``` 24 | ```ps 25 | Get-NspMsgTrackAsCSV.ps1 -NumberOfHoursToReport [-Status ] [-NspRule ] [-MailRecipientCSV ] [-NoMail] [-ReportFileName ] [-ReportRecipient ] [-ReportRecipientCSV ] [-ReportSender ] [-ReportSubject ] [-SmtpHost ] [-TenantPrimaryDomain ] [-TransactionId ] [-IpAddress ] [-MailSubject ] [-MessageId ] [-MinScl ] [-MaxScl ] [-Direction ] [-EmailAddress1 ] [-EmailAddress2 ] [] 26 | ``` 27 | ```ps 28 | Get-NspMsgTrackAsCSV.ps1 -ReportInterval [-Status ] [-NspRule ] [-MailRecipientCSV ] [-NoMail] [-ReportFileName ] [-ReportRecipient ] [-ReportRecipientCSV ] [-ReportSender ] [-ReportSubject ] [-SmtpHost ] [-TenantPrimaryDomain ] [-TransactionId ] [-IpAddress ] [-MailSubject ] [-MessageId ] [-MinScl ] [-MaxScl ] [-Direction ] [-EmailAddress1 ] [-EmailAddress2 ] [] 29 | ``` 30 | ```ps 31 | Get-NspMsgTrackAsCSV.ps1 -NoTime [-Status ] [-NspRule ] [-MailRecipientCSV ] [-NoMail] [-ReportFileName ] [-ReportRecipient ] [-ReportRecipientCSV ] [-ReportSender ] [-ReportSubject ] [-SmtpHost ] [-TenantPrimaryDomain ] [-TransactionId ] [-IpAddress ] [-MailSubject ] [-MessageId ] [-MinScl ] [-MaxScl ] [-Direction ] [-EmailAddress1 ] [-EmailAddress2 ] [] 32 | ``` 33 | 34 | ## Parameters 35 | ### Direction 36 | Default: All 37 | Filter for the direction of an email. (Inbound/Outbound) 38 | Possible values: 39 | All | FromExternal | FromLocal | None 40 | 41 | ### EmailAddress1 42 | The email address / part of the address of one of the communication participants. 43 | 44 | ### EmailAddress2 45 | The email address / part of the address of one of the communication participants. 46 | 47 | ### FromDate 48 | Mandatory if you like to use a timespan. 49 | Specifies the start date for the E-Mail filter. 50 | Please use ISO 8601 date format: "YYYY-MM-DD hh:mm:ss" 51 | E.g.: 52 | "2019-06-05 08:00" or "2019-06-05 20:00:00" 53 | 54 | ### NoMail 55 | Does not generate an E-Mail and saves the generated reports to the current execution location. 56 | Ideal for testing or manual script usage. 57 | 58 | ### IpAddress 59 | Filter for an IP address. 60 | 61 | ### MailSubject 62 | Filter for the subject / part of a subject of an email. 63 | 64 | ### MaxScl 65 | Filter for messages which have a maximal SCL value. 66 | 67 | ### MessageId 68 | Fitler for the message id of an email. 69 | 70 | ### MinScl 71 | Filter for messages which have a minimal SCL value. 72 | 73 | ### NoTime 74 | Mandatory if you do not like to specify a time value in any kind of way. 75 | No value needs to be passed here \ is just a single switch. 76 | 77 | ### NspRule 78 | Specify a rule name which is defined in NSP as E-Mail filter. 79 | 80 | ### NumberOfDays 81 | Mandatory if you like to use a number of days for filtering. 82 | Specifies the number of days for which th E-Mails should be filtered. 83 | 84 | ### NumberOfHoursToReport 85 | Mandatory if you like to use a number of hours for filtering. 86 | Specifies the number of hours for which th E-Mails should be filtered. 87 | 88 | ### ReportFileName 89 | **Default:** msgTrackReport 90 | Define a part of the complete file name. 91 | 92 | E.g.: 2019-06-05-msgTrackReport.csv 93 | 94 | ### ReportInterval 95 | Mandatory if you like to use a predefined timespan. 96 | Specifies a predefined timespan. 97 | 98 | Possible values are: 99 | daily, monthly, weekly 100 | 101 | The report will start at 00:00:00 o'clock and ends at 23:59:59 o'clock. 102 | The script call must be a day after the desired report end day. 103 | 104 | ### ReportRecipient 105 | Specifies the E-Mail recipient. It is possible to pass a comma separated list to address multiple recipients. 106 | E.g.: alice@example.com, bob@example.com 107 | 108 | ### ReportRecipientCSV 109 | 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. 110 | 111 | ### ReportSender 112 | **Default:** NoSpamProxy Report Sender \ 113 | Sets the report E-Mail sender address. 114 | 115 | ### ReportSubject 116 | **Default:** Message Track Report 117 | Sets the report E-Mail subject. 118 | 119 | ### SmtpHost 120 | Specifies the SMTP host which should be used to send the report E-Mail. 121 | It is possible to use a FQDN or IP address. 122 | 123 | ### Status 124 | Specifies a filter to get only E-Mails which are matching the defined state. 125 | 126 | Possible values are: 127 | None | Success | DispatcherError | TemporarilyBlocked | PermanentlyBlocked | PartialSuccess | DeliveryPending | Suppressed | DuplicateDrop | PutOnHold | All 128 | 129 | ### TenantPrimaryDomain 130 | Used to login into the desired NoSpamProxy tenant to run this script on. 131 | Only required if NoSpamProxy v14 is used in provider mode. 132 | 133 | ### ToDate 134 | Optional if you like to use a timespan. 135 | Specifies the end date for the E-Mail filter. 136 | Please use ISO 8601 date format: "YYYY-MM-DD hh:mm:ss" 137 | E.g.: 138 | "2019-06-05 08:00" or "2019-06-05 20:00:00" 139 | 140 | ### TransactionId 141 | Filter for the transaction ID which is provided by a NoSpamProxy Messagetrack. 142 | 143 | ## Outputs 144 | Report is stored under %TEMP% if the report is send via E-Mail the file will be removed. 145 | 146 | 147 | ## Examples 148 | ### Example 1 149 | ```ps 150 | Get-NspMsgTrackAsCSV.ps1 -NoTime -Status "Success" -ReportFileName "Example-Report" -ReportRecipient alice@example.com -ReportSender "NoSpamProxy Report Sender \" -ReportSubject "Example Report" -SmtpHost mail.example.com 151 | ``` 152 | 153 | ### EXAMPLE 2 154 | ```ps 155 | Get-NspMsgTrackAsCSV.ps1 -FromDate: "2019-06-05 08:00:00" -ToDate: "2019-06-05 20:00:00" -NoMail 156 | ``` 157 | It is mandatory to specify \. Instead \ is optional. 158 | These parameters can be combined with all other parameters except \, \, \ and \. 159 | 160 | ### EXAMPLE 3 161 | ```ps 162 | Get-NspMsgTrackAsCSV.ps1 -NumberOfDaysToReport 7 -NoMail 163 | ``` 164 | You can combine \ with all other parameters except \, \, \, \ and \. 165 | 166 | ### EXAMPLE 4 167 | ```ps 168 | Get-NspMsgTrackAsCSV.ps1 -NumberOfHoursToReport 12 -NoMail 169 | ``` 170 | You can combine \ with all other parameters except \, \, \, \ and \. 171 | 172 | ### EXAMPLE 5 173 | ```ps 174 | Get-NspMsgTrackAsCSV.ps1 -ReportInterval weekly -NoMail 175 | ``` 176 | You can combine \ with all other parameters except \, \, \, \, \ and \. 177 | 178 | ### EXAMPLE 6 179 | ```ps 180 | Get-NspMsgTrackAsCSV.ps1 -NoTime -NoMail -NspRule "All other inbound mails" 181 | ``` 182 | 183 | ### EXAMPLE 7 184 | ```ps 185 | Get-NspMsgTrackAsCSV.ps1 -NoTime -SmtpHost mail.example.com -ReportRecipientCSV "C:\Users\example\Documents\email-report.csv" 186 | ``` 187 | The CSV have to contain the header "Email" else the mail addresses cannot be read from the file. 188 | It is possible to combine \ with \. 189 | E.g: email-report.csv 190 | User,Email 191 | user1,user1@example.com 192 | user2,user2@example.com -------------------------------------------------------------------------------- /Send-BlockReportToUsers/Readme.md: -------------------------------------------------------------------------------- 1 | # Send-BlockReportToUsers.ps1 2 | 3 | This script can be used to generate a report about E-Mails which where permanently blocked. 4 | It is possible to filter the results for a specific time duration and sends the report only to specific or all affected users. 5 | This script only uses the NoSpamProxy Powershell Cmdlets to generate the report file. 6 | 7 | The output contains the following information: 8 | - sent time 9 | - sender 10 | - subject 11 | 12 | ## Usage 13 | ```ps 14 | Send-BlockReportToUsers\Send-BlockReportToUsers.ps1 -FromDate [-ToDate ] [-ReportSender ] [-ReportSubject ] [-ReportFileName ] [-SmtpHost ] [-ReportRecipient ] [-ReportRecipientCSV ] [-CheckUserExistence] [-AdServer ] [-AdPort ] [-AdBaseDN ] [-AdReportGroup ] [-AdUsername ] [-TenantPrimaryDomain ] [] 15 | ``` 16 | ```ps 17 | Send-BlockReportToUsers\Send-BlockReportToUsers.ps1 -NoTime [-ReportSender ] [-ReportSubject ] [-ReportFileName ] [-SmtpHost ] [-ReportRecipient ] [-ReportRecipientCSV ] [-CheckUserExistence] [-AdServer ] [-AdPort ] [-AdBaseDN ] [-AdReportGroup ] [-AdUsername ] [-TenantPrimaryDomain ] [] 18 | ``` 19 | ```ps 20 | Send-BlockReportToUsers\Send-BlockReportToUsers.ps1 -NumberOfDaysToReport [-ReportSender ] [-ReportSubject ] [-ReportFileName ] [-SmtpHost ] [-ReportRecipient ] [-ReportRecipientCSV ] [-CheckUserExistence] [-AdServer ] [-AdPort ] [-AdBaseDN ] [-AdReportGroup ] [-AdUsername ] [-TenantPrimaryDomain ] [] 21 | ``` 22 | ```ps 23 | Send-BlockReportToUsers\Send-BlockReportToUsers.ps1 -NumberOfHoursToReport [-ReportSender ] [-ReportSubject ] [-ReportFileName ] [-SmtpHost ] [-ReportRecipient ] [-ReportRecipientCSV ] [-CheckUserExistence] [-AdServer ] [-AdPort ] [-AdBaseDN ] [-AdReportGroup ] [-AdUsername ] [-TenantPrimaryDomain ] [] 24 | ``` 25 | ```ps 26 | Send-BlockReportToUsers\Send-BlockReportToUsers.ps1 -ReportInterval [-ReportSender ] [-ReportSubject ] [-ReportFileName ] [-SmtpHost ] [-ReportRecipient ] [-ReportRecipientCSV ] [-CheckUserExistence] [-AdServer ] [-AdPort ] [-AdBaseDN ] [-AdReportGroup ] [-AdUsername ] [-TenantPrimaryDomain ] [] 27 | ``` 28 | ```ps 29 | Send-BlockReportToUsers\Send-BlockReportToUsers.ps1 -SetAdPassword [-ReportFileName ] [-TenantPrimaryDomain ] [] 30 | ``` 31 | 32 | ## Parameters 33 | ### AdBaseDn 34 | Define the BaseDN for searching a user group in the defined AD. 35 | 36 | ### AdPort 37 | Default: 389 38 | Define a custom port to access the AD. 39 | 40 | ### AdReportGroup 41 | Define the AD user group to search for. 42 | The users in this group will receive a report. 43 | 44 | ### AdServer 45 | Define the hostname, FQDN or IP address of the desired AD. 46 | 47 | ### AdUsername 48 | Define an optional username to authenticate against the AD. 49 | A password have to be set before using . 50 | 51 | ### CheckUserExistence 52 | The switch allows to check each report recipient against the known NoSpamProxy users. 53 | Only usable if no recipient list is provided. 54 | Can have a huge performance impact. 55 | 56 | ### FromDate 57 | Mandatory if you like to use a timespan. 58 | Specifies the start date for the E-Mail filter. 59 | Please use ISO 8601 date format: "YYYY-MM-DD hh:mm:ss" 60 | E.g.: 61 | "2019-06-05 08:00" or "2019-06-05 20:00:00:00" 62 | 63 | ### MailRecipientCSV 64 | 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. 65 | 66 | ### NoTime 67 | Mandatory if you do not like to specify a time value in any kind of way. 68 | No value needs to be passed here \ is just a single switch. 69 | 70 | ### NspRule 71 | Specify a rule name which is defined in NSP as E-Mail filter. 72 | 73 | ### NumberOfDays 74 | Mandatory if you like to use a number of days for filtering. 75 | Specifies the number of days for which th E-Mails should be filtered. 76 | 77 | ### NumberOfHoursToReport 78 | Mandatory if you like to use a number of hours for filtering. 79 | Specifies the number of hours for which th E-Mails should be filtered. 80 | 81 | ### ReportFileName 82 | **Default:** reject-analysis 83 | Define a part of the complete file name. 84 | 85 | E.g.: 2019-06-05-msgTrackReport.csv 86 | 87 | ### ReportInterval 88 | Mandatory if you like to use a predefined timespan. 89 | Specifies a predefined timespan. 90 | 91 | Possible values are: 92 | daily, monthly, weekly 93 | 94 | The report will start at 00:00:00 o'clock and ends at 23:59:59 o'clock. 95 | The script call must be a day after the desired report end day. 96 | 97 | ### ReportRecipient 98 | Specifies the E-Mail recipient. It is possible to pass a comma separated list to address multiple recipients. 99 | E.g.: alice@example.com, bob@example.com 100 | 101 | ### ReportRecipientCSV 102 | 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. 103 | 104 | ### ReportSender 105 | **Default:** NoSpamProxy Report Sender \ 106 | Sets the report E-Mail sender address. 107 | 108 | ### ReportSubject 109 | **Default:** Auswertung der abgewiesenen E-Mails an Sie 110 | Sets the report E-Mail subject. 111 | 112 | ### SetAdPassword 113 | Set a password to use for authentication against the AD. 114 | The password will be saved as encrypted "NspAdReportingPass.bin" file under %APPDATA%. 115 | 116 | ### SmtpHost 117 | Specifies the SMTP host which should be used to send the report E-Mail. 118 | It is possible to use a FQDN or IP address. 119 | 120 | ### TenantPrimaryDomain 121 | Used to login into the desired NoSpamProxy tenant to run this script on. 122 | Only required if NoSpamProxy v14 is used in provider mode. 123 | 124 | ### ToDate 125 | Optional if you like to use a timespan. 126 | Specifies the end date for the E-Mail filter. 127 | Please use ISO 8601 date format: "YYYY-MM-DD hh:mm:ss" 128 | E.g.: 129 | "2019-06-05 08:00" or "2019-06-05 20:00:00" 130 | 131 | ## Outputs 132 | Report is stored under %TEMP% if the report is send via E-Mail the file will be removed. 133 | 134 | 135 | ## Examples 136 | ### Example 1 137 | ```ps 138 | Send-BlockReportToUsers.ps1 -NoTime -ReportFileName "Example-Report" -ReportRecipient alice@example.com -ReportSender "NoSpamProxy Report Sender \" -ReportSubject "Example Report" -SmtpHost mail.example.com 139 | ``` 140 | 141 | ### EXAMPLE 2 142 | ```ps 143 | Send-BlockReportToUsers.ps1 -FromDate: "2019-06-05 08:00:00" -ToDate: "2019-06-05 20:00:00" 144 | ``` 145 | It is mandatory to specify \. Instead \ is optional. 146 | These parameters can be combined with all other parameters except \, \, \ and \. 147 | 148 | ### EXAMPLE 3 149 | ```ps 150 | Send-BlockReportToUsers.ps1 -NumberOfDaysToReport 7 151 | ``` 152 | You can combine \ with all other parameters except \, \, \, \ and \. 153 | 154 | ### EXAMPLE 4 155 | ```ps 156 | Send-BlockReportToUsers.ps1 -NumberOfHoursToReport 12 157 | ``` 158 | You can combine \ with all other parameters except \, \, \, \ and \. 159 | 160 | ### EXAMPLE 5 161 | ```ps 162 | Send-BlockReportToUsers.ps1 -ReportInterval weekly 163 | ``` 164 | You can combine \ with all other parameters except \, \, \, \, \ and \. 165 | 166 | ### EXAMPLE 6 167 | ```ps 168 | Send-BlockReportToUsers.ps1 -NoTime -NspRule "All other inbound mails" 169 | ``` 170 | 171 | ### EXAMPLE 7 172 | ```ps 173 | Send-BlockReportToUsers.ps1 -NoTime -SmtpHost mail.example.com -ReportRecipientCSV "C:\Users\example\Documents\email-report.csv" 174 | ``` 175 | The CSV have to contain the header "Email" else the mail addresses cannot be read from the file. 176 | It is possible to combine \ with \. 177 | E.g: email-report.csv 178 | User,Email 179 | user1,user1@example.com 180 | user2,user2@example.com 181 | 182 | ### EXAMPLE 8 183 | ```ps 184 | Send-BlockReportToUsers.ps1 -NoTime -AdServer ad.example.com -AdBaseDN "DC=example,DC=com" -AdReportGroup "MyReportGroup" 185 | ``` 186 | Connect to AD as anonymous. 187 | 188 | ### EXAMPLE 9 189 | ```ps 190 | Send-BlockReportToUsers.ps1 -NoTime -AdServer ad.example.com -AdBaseDN "DC=example,DC=com" -AdReportGroup "MyReportGroup" -AdUsername Administrator 191 | ``` 192 | Connect to AD as Administrator, password needs to be set using .\Send-BlockReportToUsers.ps1 -SetAdPassword 193 | 194 | ### EXAMPLE 10 195 | ```ps 196 | Send-BlockReportToUsers.ps1 -SetAdPassword 197 | ``` 198 | Will wait for a user input. The input is shown in plain text! -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Get-RejectionReport (WebServices)/Get-RejectionReport.ps1: -------------------------------------------------------------------------------- 1 | param ( 2 | [Parameter(Mandatory=$false)][int] $NumberOfDaysToReport = 7, 3 | [Parameter(Mandatory=$true)][string] $SMTPHost, 4 | [Parameter(Mandatory=$true)][string] $ReportSender, 5 | [Parameter(Mandatory=$true)][string] $ReportRecipient, 6 | [Parameter(Mandatory=$false)][string] $ReportSubject = "Auswertung", 7 | [Parameter(Mandatory=$false)][int] $TopAddressesCount = 5, 8 | [Parameter(Mandatory=$false)][string[]] $excludeFromTopAddresses = @(), 9 | # only needed for v14 with enabled provider mode 10 | [Parameter(Mandatory=$false)][string] $TenantPrimaryDomain 11 | ) 12 | 13 | $nspVersion = (Get-ItemProperty -Path HKLM:\SOFTWARE\NoSpamProxy\Components -ErrorAction SilentlyContinue).'Intranet Role' 14 | if ($nspVersion -gt '14.0') { 15 | try { 16 | Connect-Nsp -IgnoreServerCertificateErrors -ErrorAction Stop 17 | } catch { 18 | $e = $_ 19 | Write-Warning "Not possible to connect with the NoSpamProxy. Please check the error message below." 20 | $e |Format-List * -Force 21 | EXIT 22 | } 23 | if ($(Get-NspIsProviderModeEnabled) -eq $true) { 24 | if ($null -eq $TenantPrimaryDomain -OR $TenantPrimaryDomain -eq "") { 25 | Write-Host "Please provide a TenantPrimaryDomain to run this script with NoSpamProxy v14 in provider mode." 26 | EXIT 27 | } else { 28 | # NSP v14 has a new authentication mechanism, Connect-Nsp is required to authenticate properly 29 | # -IgnoreServerCertificateErrors allows the usage of self-signed certificates 30 | Connect-Nsp -IgnoreServerCertificateErrors -PrimaryDomain $TenantPrimaryDomain 31 | } 32 | } 33 | } 34 | 35 | $reportFileName = [System.IO.Path]::Combine($Env:TEMP, "reject-analysis.html") 36 | $totalRejected = 0 37 | $tempRejected = 0 38 | $permanentRejected = 0 39 | $reputationRejected = 0 40 | $rblRejected = 0 41 | $cyrenSpamRejected = 0 42 | $cyrenAVRejected = 0 43 | $cyrenIPRepRejected = 0 44 | $surblRejected = 0 45 | $characterSetRejected = 0 46 | $wordRejected = 0 47 | $contentrejected = 0 48 | $greylistrejected = 0 49 | $rdnsPermanentRejected = 0 50 | $decryptPolicyRejected = 0 51 | $onBodyRejected = 0 52 | $onEnvelopeRejected = 0 53 | $dateStart = (Get-Date).AddDays(-$NumberOfDaysToReport) 54 | $dateStop = Get-Date 55 | $dateTo = Get-Date -format "dd.MM.yyyy" 56 | $dateFrom = $dateStart.ToString("dd.MM.yyyy") 57 | $topSpammers = @{} 58 | 59 | Write-Host "Getting MessageTracks from NoSpamProxy for..." 60 | Write-Host "`tTemporarily Blocked" 61 | $messageTracks = Get-NSPMessageTrack -From $dateStart -Status TemporarilyBlocked -Directions FromExternal -WithActions -WithDeliveryAttempts -WithFilters -WithOperations -WithAddresses 62 | 63 | $totalRejected += $messageTracks.Count 64 | $tempRejected += $messageTracks.Count 65 | 66 | foreach ($item in $messageTracks) 67 | { 68 | $sender = ($item.Addresses|?{[string]$_.AddressType -eq "Sender"}).Address 69 | if($sender -ne $null) { 70 | $topSpammers[$sender]++ 71 | } 72 | foreach ($action in $item.Actions){ 73 | if ($action.Name -eq "greylisting" -and $action.Decision -notcontains "Pass") 74 | { 75 | $onEnvelopeRejected++ 76 | $greylistrejected++ 77 | } 78 | } 79 | } 80 | 81 | Write-Host "`tPermanently Blocked" 82 | $messageTracks = Get-NSPMessageTrack -From $dateStart -Status PermanentlyBlocked -Directions FromExternal -WithActions -WithDeliveryAttempts -WithFilters -WithOperations -WithAddresses 83 | 84 | $totalRejected += $messageTracks.Count 85 | $permanentRejected += $messageTracks.Count 86 | 87 | foreach ($item in $messageTracks) 88 | { 89 | $sender = ($item.Addresses|?{[string]$_.AddressType -eq "Sender"}).Address 90 | if($sender -ne $null) { 91 | $topSpammers[$sender]++ 92 | } 93 | foreach ($permanentvalidationentry in $item.Filters) 94 | { 95 | if ($permanentvalidationentry.Name -eq "realtimeBlocklist" -and $permanentvalidationentry.Scl -gt 0) 96 | { 97 | $rblRejected++ 98 | $onEnvelopeRejected++ 99 | } 100 | 101 | if ($permanentvalidationentry.Name -eq "surblFilter" -and $permanentvalidationentry.Scl -gt 0) 102 | { 103 | $surblRejected++ 104 | $onBodyRejected++ 105 | } 106 | 107 | if ($permanentvalidationentry.Name -eq "cyrenFilter" -and $permanentvalidationentry.Scl -gt 0) 108 | { 109 | $cyrenSpamRejected++ 110 | $onBodyRejected++ 111 | } 112 | 113 | if ($permanentvalidationentry.Name -eq "characterSetFilter" -and $permanentvalidationentry.Scl -gt 0) 114 | { 115 | $characterSetRejected++ 116 | $onBodyRejected++ 117 | } 118 | 119 | if ($permanentvalidationentry.Name -eq "wordFilter" -and $permanentvalidationentry.Scl -gt 0) 120 | { 121 | $wordRejected++ 122 | $onBodyRejected++ 123 | } 124 | 125 | if (($permanentvalidationentry.Name -eq "validateSignatureAndDecrypt") -and ($permanentvalidationentry.Decision -notcontains "Pass" )) 126 | { 127 | $decryptPolicyRejected++ 128 | $onBodyRejected++ 129 | } 130 | 131 | if (($permanentvalidationentry.Name -eq "reputation") -and ($permanentvalidationentry.Scl -gt 0 )) 132 | { 133 | $reputationRejected++ 134 | $onEnvelopeRejected++ 135 | } 136 | if (($permanentvalidationentry.Name -eq "cyrenIpReputationFilter") -and ($permanentvalidationentry.Scl -gt 0 )) 137 | { 138 | $cyrenIPRepRejected++ 139 | $onEnvelopeRejected++ 140 | } 141 | 142 | } 143 | 144 | foreach ($action in $item.Actions) 145 | { 146 | if ($action.Name -eq "cyrenAction" -and $action.Decision -notcontains "Pass") 147 | { 148 | $cyrenAVRejected++ 149 | $onBodyRejected++ 150 | } 151 | if ($action.Name -eq "malwareScan" -and $action.Decision -notcontains "Pass") 152 | { 153 | $cyrenAVRejected++ 154 | $onBodyRejected++ 155 | } 156 | if ($action.Name -eq "ContentFiltering" -and $action.Decision -notcontains "Pass") 157 | { 158 | $onBodyRejected++ 159 | $contentrejected++ 160 | } 161 | } 162 | } 163 | Write-Host "Evaluating top spammers" 164 | $topSpammers = $topSpammers.GetEnumerator() | ?{$_.Name -notin $excludeFromTopAddresses} | sort Value -Descending | select -First $TopAddressesCount 165 | 166 | 167 | $ownedDomains = (Get-NspOwnedDomain).Domain 168 | 169 | Write-Host "Evaluating top Senders/Recipients Outgoing" 170 | $messageTracks = (Get-NSPMessageTrack -From $dateStart -Directions FromLocal -Status Success -WithAddresses|?{($_.Addresses|?{[string]$_.AddressType -eq "Recipient" -and $_.Domain -in $ownedDomains}) -eq $null}) 171 | 172 | $outboundmessages = $messageTracks.Count 173 | $topLocal = @{} 174 | $topLocal["Sender"] = @{} 175 | $topLocal["Recipient"] = @{} 176 | 177 | foreach ($addr in ($messageTracks.Addresses)) { 178 | if(($addr.AddressType -like "Sender") -OR ($addr.AddressType -like "Recipient")){ 179 | $topLocal[[string]$addr.AddressType][$addr.Address]++ 180 | } 181 | } 182 | 183 | $topRecipientsOutgoing = ($topLocal["Recipient"].GetEnumerator() | ?{$_.Name -notin $excludeFromTopAddresses} | Sort Value -Descending | select -First $TopAddressesCount) 184 | $topSendersOutgoing = ($topLocal["Sender"].GetEnumerator() | ?{$_.Name -notin $excludeFromTopAddresses} | Sort Value -Descending | select -First $TopAddressesCount) 185 | 186 | 187 | 188 | Write-Host "Evaluating top Senders/Recipients Incoming" 189 | $messageTracks = Get-NSPMessageTrack -From $dateStart -Directions FromExternal -Status Success -WithAddresses 190 | 191 | $inboundmessages = $messageTracks.Count 192 | $topExternal = @{} 193 | $topExternal["Sender"] = @{} 194 | $topExternal["Recipient"] = @{} 195 | 196 | foreach ($addr in $messageTracks.Addresses) { 197 | if(($addr.AddressType -like "Sender") -OR ($addr.AddressType -like "Recipient")){ 198 | $topExternal[[string]$addr.AddressType][$addr.Address]++ 199 | } 200 | } 201 | 202 | $topRecipientsIncoming = ($topExternal["Recipient"].GetEnumerator() | ?{$_.Name -notin $excludeFromTopAddresses} | Sort Value -Descending | select -First $TopAddressesCount) 203 | $topSendersIncoming = ($topExternal["Sender"].GetEnumerator() | ?{$_.Name -notin $excludeFromTopAddresses} | Sort Value -Descending | select -First $TopAddressesCount) 204 | 205 | 206 | 207 | $mailsprocessed = $outboundmessages+$inboundmessages 208 | 209 | if ($inboundmessages -eq 0) { 210 | $blockedpercentage = 0 211 | } else { 212 | $blockedpercentage = [Math]::Round($totalRejected/$inboundmessages*100,2) 213 | } 214 | 215 | if ($totalRejected -eq 0) { 216 | $cyrenspamblockpercentage = 0 217 | $cyrenavblockpercentage = 0 218 | $surblblockedpercentage = 0 219 | $charactersetblockedpercentage = 0 220 | $wordrejectedblockedpercentage = 0 221 | $decryptpolicyblockedpercentage = 0 222 | $rblRejectedpercentage = 0 223 | $contentrejectedpercentage = 0 224 | $greylistrejectedpercentage = 0 225 | $reputationRejectedpercentage = 0 226 | $cyreniprepRejectedpercentage = 0 227 | } else { 228 | $cyrenspamblockpercentage = [Math]::Round($cyrenSpamRejected/$totalRejected*100,2) 229 | $cyrenavblockpercentage = [Math]::Round($cyrenAVRejected/$totalRejected*100,2) 230 | $surblblockedpercentage = [Math]::Round($surblRejected/$totalRejected*100,2) 231 | $charactersetblockedpercentage = [Math]::Round($characterSetRejected/$totalRejected*100,2) 232 | $wordrejectedblockedpercentage = [Math]::Round($wordRejected/$totalRejected*100,2) 233 | $decryptpolicyblockedpercentage = [Math]::Round($decryptPolicyRejected/$totalRejected*100,2) 234 | $rblRejectedpercentage = [Math]::Round($rblRejected/$totalRejected*100,2) 235 | $contentrejectedpercentage = [Math]::Round($contentRejected/$totalRejected*100,2) 236 | $greylistrejectedpercentage = [Math]::Round($greylistRejected/$totalRejected*100,2) 237 | $reputationRejectedpercentage = [Math]::Round($reputationRejected/$totalRejected*100,2) 238 | $cyreniprepRejectedpercentage = [Math]::Round($cyrenIPRepRejected/$totalRejected*100,2) 239 | } 240 | 241 | Write-Host " " 242 | Write-Host "TemporaryReject Total:" $tempRejected 243 | Write-Host "PermanentReject Total:" $permanentRejected 244 | Write-Host "TotalReject:" $totalRejected 245 | Write-Host "Generating Report..." 246 | 247 | 248 | $global:htmlout = " 249 | 250 | Auswertung der abgewiesenen E-Mails 251 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 |
"+ $dateFrom +" bis "+ $dateTo +" ("+$NumberOfDaysToReport+" Tage)CountPercent
Mails Processed" + $mailsprocessed +" 
Sent" + $outboundmessages +" 
Received" + $inboundmessages +" 
Mails blocked" + $totalRejected +"" + $blockedpercentage +" %
Realtime Blocklist Check" + $rblRejected +"" + $rblRejectedpercentage +" %
Reputation Check" + $reputationRejected +"" + $reputationRejectedpercentage +" %
Cyren AntiSpam" + $cyrenSpamRejected +"" + $cyrenspamblockpercentage +" %
Cyren Premium AntiVirus" + $cyrenAVRejected +"" + $cyrenavblockpercentage +" %
Cyren IP Reputation" + $cyrenIPRepRejected +"" + $cyreniprepRejectedpercentage +" %
Spam URI Realtime Blocklists" + $surblRejected +"" + $surblblockedpercentage +" %
Allowed Unicode Character Sets" + $characterSetRejected +"" + $charactersetblockedpercentage +" %
Word Matching" + $wordRejected +"" + $wordrejectedblockedpercentage +" %
DecryptPolicy Reject" + $decryptPolicyRejected +"" + $decryptpolicyblockedpercentage +" %
ContentFiltering" + $contentrejected + "" + $contentrejectedpercentage + " %
Greylisting" + $greylistrejected + "" + $greylistrejectedpercentage + " %
" 284 | 285 | 286 | function enumerateAddressList($addrlist) { 287 | foreach($addr in $addrlist) { 288 | $global:htmlout += "" + $addr.Key + "" + $addr.Value + " " 289 | } 290 | } 291 | 292 | $global:htmlout += " 293 | 294 | " 295 | enumerateAddressList($topSendersOutgoing) 296 | $global:htmlout += "" 297 | enumerateAddressList($topRecipientsIncoming) 298 | $global:htmlout += "
Top Local E-Mail AddressesCount 
Most E-Mails From  
Most E-Mails To  
" 299 | 300 | 301 | 302 | $global:htmlout += " 303 | 304 | " 305 | enumerateAddressList($topSendersIncoming) 306 | $global:htmlout += "" 307 | enumerateAddressList($topRecipientsOutgoing) 308 | $global:htmlout += "" 309 | enumerateAddressList($topSpammers) 310 | $global:htmlout += "
Top External E-Mail AddressesCount 
Most E-Mails From  
Most E-Mails To  
Top Spammers  
" 311 | 312 | $global:htmlout | Out-File $reportFileName 313 | 314 | Write-Host "Report Generated Successfully" 315 | 316 | "Sending report to $ReportRecipient" 317 | Send-MailMessage -SmtpServer $SmtpHost -From $ReportSender -To $ReportRecipient -Subject $ReportSubject -Body "Im Anhang dieser E-Mail finden Sie den Bericht mit der Auswertung der abgewiesenen E-Mails." -Attachments $reportFileName 318 | Write-Host "Doing some cleanup.." 319 | Remove-Item $reportFileName 320 | Write-Host "Done." -------------------------------------------------------------------------------- /Get-NspTlsReport/Get-NspTlsReport.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Name: Get-NspTlsReport.ps1 4 | Create report for in- and outbound E-Mails which did not use TLS. 5 | Requires NSP version 13.0.19147.917 or later. 6 | 7 | .DESCRIPTION 8 | This script can be used to generate a report about E-Mails which where send or received without TLS 9 | It is possible to send the report via E-Mail and to filter the results for a specific time duration. 10 | This script only uses the NoSpamProxy Powershell Cmdlets to generate the report file. 11 | 12 | .PARAMETER FromDate 13 | Mandatory if you like to use a timespan. 14 | Specifies the start date for the E-Mail filter. 15 | Please use ISO 8601 date format: "YYYY-MM-DD hh:mm:ss" 16 | E.g.: 17 | "2018-11-16 08:00" or "2018-11-16 20:00:00" 18 | 19 | .PARAMETER NoTime 20 | Mandatory if you do not like to specify a time value in any kind of way. 21 | No value needs to be passed here is just a single switch. 22 | 23 | .PARAMETER NspRule 24 | Specify a rule name which is defined in NSP as E-Mail filter. 25 | 26 | .PARAMETER NumberOfDays 27 | Mandatory if you like to use a number of days for filtering. 28 | Specifies the number of days for which th E-Mails should be filtered. 29 | 30 | .PARAMETER NumberOfHoursToReport 31 | Mandatory if you like to use a number of hours for filtering. 32 | Specifies the number of hours for which th E-Mails should be filtered. 33 | 34 | .PARAMETER ReportFileName 35 | Default: TLSReport 36 | Sets the reports file name. No file extension required. 37 | 38 | .PARAMETER ReportInterval 39 | Mandatory if you like to use a predifined timespan. 40 | Specifies a predifined timespan. 41 | Possible values are: 42 | daily, monthly, weekly 43 | The report will start at 00:00:00 o'clock and ends at 23:59:59 o'clock. 44 | The script call must be a day after the desired report end day. 45 | 46 | .PARAMETER ReportRecipient 47 | Specifies the E-Mail recipient. It is possible to pass a comma seperated list to address multiple recipients. 48 | E.g.: alice@example.com,bob@example.com 49 | 50 | .PARAMETER ReportRecipientCSV 51 | 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. 52 | 53 | .PARAMETER ReportSender 54 | Default: NoSpamProxy Report Sender 55 | Sets the report E-Mail sender address. 56 | 57 | .PARAMETER ReportSubject 58 | Default: NSP TLS Report 59 | Sets the report E-Mail subject. 60 | 61 | .PARAMETER SmtpHost 62 | Specifies the SMTP host which should be used to send the report E-Mail. 63 | It is possible to use a FQDN or IP address. 64 | 65 | .PARAMETER Status 66 | Specifies a filter to get only E-Mails which are matching the defined state. 67 | Possible values are: 68 | None | Success | DispatcherError | TemporarilyBlocked | PermanentlyBlocked | PartialSuccess | DeliveryPending | Suppressed | DuplicateDrop | PutOnHold | All 69 | 70 | .PARAMETER TenantPrimaryDomain 71 | Used to login into the desired NoSpamProxy tenant to run this script on. 72 | Only required if NoSpamProxy v14 is used in provider mode. 73 | 74 | .PARAMETER ToDate 75 | Optional if you like to use a timespan. 76 | Specifies the end date for the E-Mail filter. 77 | Please use ISO 8601 date format: "YYYY-MM-DD hh:mm:ss" 78 | E.g.: 79 | "2018-11-16 08:00" or "2018-11-16 20:00:00" 80 | 81 | .OUTPUTS 82 | Report is stored under %TEMP%\TLSReport.html unless a custom parameter is given. 83 | 84 | .NOTES 85 | Version: 1.1.0 86 | Author: Jan Jaeschke 87 | Creation Date: 2022-06-07 88 | Purpose/Change: added TLS version details 89 | 90 | .LINK 91 | https://www.nospamproxy.de 92 | https://github.com/noSpamProxy 93 | 94 | .EXAMPLE 95 | .\Get-NspTlsReport.ps1 -NoTime -Status "Success" -ReportFileName "Example-Report" -ReportRecipient alice@example.com -ReportSender "NoSpamProxy Report Sender " -ReportSubject "Example Report" -SmtpHost mail.example.com 96 | 97 | .EXAMPLE 98 | .\Get-NspTlsReport.ps1 -FromDate: "2018-10-14 08:00" -ToDate: "2018-10-14 20:00" -NoMail 99 | It is mandatory to specify . Instead is optional. 100 | These parameters can be combined with all other parameters except and . 101 | 102 | .EXAMPLE 103 | .\Get-NspTlsReport.ps1 -NumberOfDaysToReport 7 -NoMail 104 | You can combine with all other parameters except , and . 105 | 106 | .EXAMPLE 107 | .\Get-NspTlsReport.ps1 -NumberOfHoursToReport 12 -NoMail 108 | You can combine with all other parameters except , and . 109 | 110 | .EXAMPLE 111 | .\Get-NspTlsReport.ps1 -ReportInterval weekly -NoMail 112 | You can combine with all other parameters except , , and . 113 | 114 | .EXAMPLE 115 | .\Get-NspTlsReport.ps1 -NoTime -NoMail -NspRule "All other inbound mails" 116 | 117 | .EXAMPLE 118 | .\Get-NspTlsReport.ps1 -NoTime -SmtpHost mail.example.com -ReportRecipientCSV "C:\Users\example\Documents\email-report.csv" 119 | The CSV have to contain the header "Email" else the mail addresses cannot be read from the file. 120 | It is possible to combine with . 121 | E.g: email-report.csv 122 | User,Email 123 | user1,user1@example.com 124 | user2,user2@example.com 125 | #> 126 | param ( 127 | # userParams are used for filtering 128 | # set start date for filtering 129 | [Parameter(Mandatory=$true, ParameterSetName="dateSpanSet")][ValidatePattern("^([0-9]{4})-?(1[0-2]|0[1-9])-?(3[01]|0[1-9]|[12][0-9])\s(2[0-3]|[01][0-9]):?([0-5][0-9]):?([0-5][0-9])?$")][string] $FromDate, 130 | # set end date for filtering 131 | [Parameter(Mandatory=$false, ParameterSetName="dateSpanSet")][ValidatePattern("^([0-9]{4})-?(1[0-2]|0[1-9])-?(3[01]|0[1-9]|[12][0-9])\s(2[0-3]|[01][0-9]):?([0-5][0-9]):?([0-5][0-9])?$")][string] $ToDate, 132 | # set number of days for filtering 133 | [Parameter(Mandatory=$true, ParameterSetName="numberOfDaysSet")][ValidatePattern("[0-9]+")][string] $NumberOfDaysToReport, 134 | # set number of hours for filtering 135 | [Parameter(Mandatory=$true, ParameterSetName="numberOfHoursSet")][int] $NumberOfHoursToReport, 136 | # set reporting intervall 137 | [Parameter(Mandatory=$true, ParameterSetName="reportIntervalSet")][ValidateSet('daily','weekly','monthly')][string] $ReportInterval, 138 | # if set not time duration have to be set the E-Mail of the last few hours will be filtered 139 | [Parameter(Mandatory=$true, ParameterSetName="noTimeSet")][switch] $NoTime, # no userParam just here for better Get-Help output 140 | # set E-Mail status which will be filtered 141 | [Parameter(Mandatory=$false)][string] $Status = "Success", 142 | # set NSP Rule for filtering 143 | [Parameter(Mandatory=$false)][string] $NspRule, 144 | # additional params are used for additional actions 145 | # generate the report but do not send an E-Mail 146 | [Parameter(Mandatory=$false)][switch]$NoMail, 147 | # change report filename 148 | [Parameter(Mandatory=$false)][string] $ReportFileName = "TLSReport" , 149 | # set report recipient only valid E-Mail addresses are allowed 150 | [Parameter(Mandatory=$false)][ValidatePattern("^?$")][string[]] $ReportRecipient, 151 | # set path to csv file containing report recipient E-Mail addresses 152 | [Parameter(Mandatory=$false)][string] $ReportRecipientCSV, 153 | # set report sender address only a valid E-Mail addresse is allowed 154 | [Parameter(Mandatory=$false)][ValidatePattern("^?$")][string] $ReportSender = "NoSpamProxy Report Sender ", 155 | # change report E-Mail subject 156 | [Parameter(Mandatory=$false)][string] $ReportSubject = "NSP TLS Report", 157 | # set used SMTP host for sending report E-Mail only a valid IP address or FQDN is allowed 158 | [Parameter(Mandatory=$false)][ValidatePattern("^(((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(((?!-)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9]\.)+[a-zA-Z]{2,63}))$")][string] $SmtpHost, 159 | # only needed for v14 with enabled provider mode 160 | [Parameter(Mandatory=$false)][string] $TenantPrimaryDomain 161 | ) 162 | 163 | #-------------------Functions---------------------- 164 | # process actual MessageTracks - compare Mail From and add htmlContent 165 | function processMessageTracks($tmpMessageTracks, $messageDirection){ 166 | $returnValues = @{} 167 | $returnValues.sendersWithoutTLS = @() 168 | foreach($messageTrack in $tmpMessageTracks){ 169 | if($messageDirection -eq "FromExternal"){ 170 | if ($useV14Queries) { 171 | $tls = ($messageTrack.TlsProtocol) 172 | } else { 173 | $tls = ($messageTrack.SenderConnectionSecurity) 174 | } 175 | }else{ 176 | if ($useV14Queries) { 177 | $tls = ($messageTrack.DeliveryAttempts | Where-Object {$_.Status -eq "Success"}).TlsProtocol 178 | } else { 179 | $tls = ($messageTrack.DeliveryAttempts | Where-Object {$_.Status -eq "Success"}).ConnectionSecurity 180 | } 181 | } 182 | if($null -eq $tls -OR $tls -eq "None"){ 183 | # number of the successfull send/received messages without 184 | $returnValues.numberOfMessagesWithoutTls = $returnValues.numberOfMessagesWithoutTls+1 185 | if($messageDirection -eq "FromExternal"){ 186 | $sender = ($messagetrack.Addresses|Where-Object{[string]$_.AddressType -eq "Sender"}).Address 187 | }else{ 188 | $sender = ($messagetrack.Addresses|Where-Object{[string]$_.AddressType -eq "Recipient"}).Address 189 | } 190 | 191 | if($null -eq $sender){ 192 | continue 193 | }else{ 194 | $returnValues.sendersWithoutTLS += "$sender
" 195 | } 196 | } else{ 197 | if($messageDirection -eq "FromExternal"){ 198 | switch($tls){ 199 | "Tls"{ 200 | $returnValues.numberOfTls10 = $returnValues.numberOfTls10+1 201 | break; 202 | } 203 | "Tls11"{ 204 | $returnValues.numberOfTls11 = $returnValues.numberOfTls11+1 205 | break; 206 | } 207 | "Tls12"{ 208 | $returnValues.numberOfTls12 = $returnValues.numberOfTls12+1 209 | break; 210 | } 211 | "Tls13"{ 212 | $returnValues.numberOfTls13 = $returnValues.numberOfTls13+1 213 | break; 214 | } 215 | } 216 | } 217 | } 218 | } 219 | $returnValues.sendersWithoutTLS = $returnValues.sendersWithoutTLS | Get-Unique 220 | return $returnValues 221 | } 222 | # get data from message tracks and call the processing 223 | # input the desired direction of messages 224 | function getData($messageDirection){ 225 | $returnValues = @{} 226 | 227 | # number of messages which will be skipped by Get-NspMessageTrack, will increase by 100 at each call 228 | $skipMessageTracks = 0 229 | while($getMessageTracks -eq $true){ 230 | if($skipMessageTracks -eq 0){ 231 | $messageTracks = Get-NSPMessageTrack @cleanedParams -WithOperations -WithDeliveryAttempts -WithTlsSettings -WithActions -WithAddresses -Directions $messageDirection -First 100 232 | # number of messages which where send/received successfully 233 | $returnValues.numberOfMessages += $messageTracks.Count 234 | }else{ 235 | $messageTracks = Get-NSPMessageTrack @cleanedParams -WithOperations -WithDeliveryAttempts -WithTlsSettings -WithActions -WithAddresses -Directions $messageDirection -First 100 -Skip $skipMessageTracks 236 | # number of messages which where send/received successfully 237 | $returnValues.numberOfMessages += $messageTracks.Count 238 | } 239 | $processResult = processMessageTracks $messageTracks $messageDirection 240 | $returnValues.numberOfMessagesWithoutTls += $processResult.numberOfMessagesWithoutTls 241 | $returnValues.sendersWithoutTLS += $processResult.sendersWithoutTLS 242 | $returnValues.numberOfTls10 += $processResult.numberOfTls10 243 | $returnValues.numberOfTls11 += $processResult.numberOfTls11 244 | $returnValues.numberOfTls12 += $processResult.numberOfTls12 245 | $returnValues.numberOfTls12 += $processResult.numberOfTls13 246 | # exit condition 247 | if($messageTracks){ 248 | $skipMessageTracks = $skipMessageTracks+100 249 | Write-Host $skipMessageTracks 250 | }else{ 251 | $getMessageTracks = $false 252 | break 253 | } 254 | } 255 | return $returnValues 256 | } 257 | # generate HMTL report 258 | function createHTML($resultFromExternal, $percentFromExternal, $resultFromLocal, $percentFromLocal) { 259 | $percentFromExternalTls10 = [Math]::Round($($resultFromExternal.numberOfTls10)/$($resultFromExternal.numberOfMessages)*100,2) 260 | $percentFromExternalTls11 = [Math]::Round($($resultFromExternal.numberOfTls11)/$($resultFromExternal.numberOfMessages)*100,2) 261 | $percentFromExternalTls12 = [Math]::Round($($resultFromExternal.numberOfTls12)/$($resultFromExternal.numberOfMessages)*100,2) 262 | $percentFromExternalTls13 = [Math]::Round($($resultFromExternal.numberOfTls13)/$($resultFromExternal.numberOfMessages)*100,2) 263 | $htmlOut = 264 | " 265 | 266 | Auswertung der TLS-Sicherheit 267 | 271 | 272 | 273 |

Auswertung der TLS-Sicherheit

274 |
275 | Anzahl aller eingehenden Verbindungen: $($resultFromExternal.numberOfMessages)
276 | Davon waren unverschlüsselt: $($resultFromExternal.numberOfMessagesWithoutTls) ($percentFromExternal%)

277 | Davon waren Tls 1.0 verschlüsselt: $($resultFromExternal.numberOfTls10) ($percentFromExternalTls10%)
278 | Davon waren Tls 1.1 verschlüsselt: $($resultFromExternal.numberOfTls11) ($percentFromExternalTls11%)
279 | Davon waren Tls 1.2 verschlüsselt: $($resultFromExternal.numberOfTls12) ($percentFromExternalTls12%)
280 | Davon waren Tls 1.3 verschlüsselt: $($resultFromExternal.numberOfTls13) ($percentFromExternalTls13%)

281 | Anzahl aller ausgehenden Verbindungen: $($resultFromLocal.numberOfMessages)
282 | Davon waren unverschlüsselt: $($resultFromLocal.numberOfMessagesWithoutTls) ($percentFromLocal%)

283 | Adressen, die unverschlüsselt geschickt haben:
284 | $($($resultFromExternal.sendersWithoutTLS) | Out-String) 285 |

286 | Adressen, an die unverschlüsselt geschickt wurde:
287 | $($($resultFromLocal.sendersWithoutTLS) | Out-String) 288 | 289 | " 290 | $htmlOut | Out-File "$reportFile" 291 | } 292 | # send report E-Mail 293 | function sendMail($ReportRecipient, $ReportRecipientCSV){ 294 | if ($ReportRecipient -and $ReportRecipientCSV){ 295 | $recipientCSV = Import-Csv $ReportRecipientCSV 296 | $mailRecipient = @($ReportRecipient;$recipientCSV.Email) 297 | } 298 | elseif($ReportRecipient){ 299 | $mailRecipient = $ReportRecipient 300 | } 301 | elseif($ReportRecipientCSV){ 302 | $csv = Import-Csv $ReportRecipientCSV 303 | $mailRecipient = $csv.Email 304 | } 305 | if ($SmtpHost -and $mailRecipient){ 306 | Send-MailMessage -SmtpServer $SmtpHost -From $ReportSender -To $mailRecipient -Subject $ReportSubject -Body "Im Anhang dieser E-Mail finden Sie einen automatisch genrerierten Bericht vom NoSpamProxy" -Attachments $reportFile 307 | } 308 | } 309 | 310 | #-------------------Variables---------------------- 311 | $fileDate = Get-Date -UFormat "%Y-%m-%d" 312 | if ($NumberOfHoursToReport){ 313 | $FromDate = (Get-Date).AddHours(-$NumberOfHoursToReport) 314 | } 315 | if ($ReportInterval){ 316 | # equals the day where the script runs 317 | $reportEndDay = (Get-Date -Date ((Get-Date).AddDays(-1)) -UFormat "%Y-%m-%d") 318 | switch ($ReportInterval){ 319 | 'daily'{ 320 | $reportStartDay = $reportEndDay 321 | } 322 | 'weekly'{ 323 | $reportStartDay = (Get-Date -Date ((Get-Date).AddDays(-7)) -UFormat "%Y-%m-%d") 324 | } 325 | 'monthly'{ 326 | $reportStartDay = (Get-Date -Date ((Get-Date).AddMonths((-1))) -UFormat "%Y-%m-%d") 327 | } 328 | } 329 | $FromDate = "$reportStartDay 00:00:00" 330 | $ToDate = "$reportEndDay 23:59:59" 331 | $fileDate = $reportEndDay 332 | $reportFile = "$ENV:TEMP\" + "$fileDate-$ReportFileName" + ".html" 333 | } 334 | $reportFile = "$ENV:TEMP\" + "$ReportFileName" + ".html" 335 | 336 | if ($NumberOfHoursToReport){ 337 | $FromDate = (Get-Date).AddHours(-$NumberOfHoursToReport) 338 | } 339 | # create hashtable which will preserve the order of the added items and mapps userParams into needed parameter format 340 | $userParams = [ordered]@{ 341 | From = $FromDate 342 | To = $ToDate 343 | Age = $NumberOfDaysToReport 344 | Rule = $NspRule 345 | Status = $Status 346 | } 347 | # for loop problem because hashtable have no indices to access items, this is a workaround 348 | # new hashtable which only holds non empty userParams 349 | $cleanedParams=@{} 350 | # this loop removes all empty userParams and add the otherones into the new hashtable 351 | foreach ($userParam in $userParams.Keys) { 352 | if ($($userParams.Item($userParam)) -ne "") { 353 | $cleanedParams.Add($userParam, $userParams.Item($userParam)) 354 | } 355 | } 356 | # end workaround 357 | # condition to run Main part, if false program will end 358 | $getMessageTracks = $true 359 | 360 | 361 | #--------------------Main----------------------- 362 | $nspVersion = (Get-ItemProperty -Path HKLM:\SOFTWARE\NoSpamProxy\Components -ErrorAction SilentlyContinue).'Intranet Role' 363 | if ($nspVersion -gt '14.0') { 364 | try { 365 | Connect-Nsp -IgnoreServerCertificateErrors -ErrorAction Stop 366 | } catch { 367 | $e = $_ 368 | Write-Warning "Not possible to connect with the NoSpamProxy. Please check the error message below." 369 | $e |Format-List * -Force 370 | EXIT 371 | } 372 | if ($(Get-NspIsProviderModeEnabled) -eq $true) { 373 | if ($null -eq $TenantPrimaryDomain -OR $TenantPrimaryDomain -eq "") { 374 | Write-Host "Please provide a TenantPrimaryDomain to run this script with NoSpamProxy v14 in provider mode." 375 | EXIT 376 | } else { 377 | # NSP v14 has a new authentication mechanism, Connect-Nsp is required to authenticate properly 378 | # -IgnoreServerCertificateErrors allows the usage of self-signed certificates 379 | Connect-Nsp -IgnoreServerCertificateErrors -PrimaryDomain $TenantPrimaryDomain 380 | } 381 | } 382 | } 383 | if ($nspVersion -ge '14.0.231') { 384 | $useV14Queries = $true 385 | } 386 | # check NSP version for compatibility 387 | if(!((Get-NspIntranetRole).Version -ge [version]"13.0.19147.917")){ 388 | throw "A minimum of NSP Version 13.0.19147.917 is needed, please update. Your version: $((Get-NspIntranetRole).Version)" 389 | } 390 | 391 | Write-Host "Getting data for E-Mails from External" 392 | $resultFromExternal = getData "FromExternal" 393 | if($null -eq $($resultFromExternal.sendersWithoutTLS)){ 394 | $resultFromExternal.sendersWithoutTLS = 0 395 | $percentFromExternal = 0 396 | }else{ 397 | $percentFromExternal = [Math]::Round($($resultFromExternal.numberOfMessagesWithoutTls)/$($resultFromExternal.numberOfMessages)*100,2) 398 | } 399 | 400 | Write-Host "Getting data for E-Mails from local" 401 | $resultFromLocal = getdata "FromLocal" 402 | if($null -eq $($resultFromLocal.numberOfMessagesWithoutTls)){ 403 | $resultFromLocal.numberOfMessagesWithoutTls = 0 404 | $percentFromLocal = 0 405 | }else{ 406 | $percentFromLocal = [Math]::Round($($resultFromLocal.numberOfMessagesWithoutTls)/$($resultFromLocal.numberOfMessages)*100,2) 407 | } 408 | 409 | Write-Host "Generating Report" 410 | createHTML $resultFromExternal $percentFromExternal $resultFromLocal $percentFromLocal 411 | # send mail if switch is not used and delete temp report file 412 | if (!$NoMail){ 413 | sendMail $ReportRecipient $ReportRecipientCSV 414 | Remove-Item $reportFile 415 | } else { 416 | Move-Item -Path $reportFile -Destination "$PSScriptRoot\$(Split-Path -Path $reportFile -Leaf)" 417 | } 418 | Write-Host "Skript durchgelaufen" -------------------------------------------------------------------------------- /Get-RejectionReport (Database)/Get-RejectionReport.ps1: -------------------------------------------------------------------------------- 1 | param ( 2 | [Parameter(Mandatory=$false, ParameterSetName="default")][int] $NumberOfDaysToReport = 7, 3 | [Parameter(Mandatory=$true, ParameterSetName="default")][string] $SMTPHost, 4 | [Parameter(Mandatory=$true, ParameterSetName="default")][string] $ReportSender, 5 | [Parameter(Mandatory=$true, ParameterSetName="default")][string] $ReportRecipient, 6 | [Parameter(Mandatory=$false, ParameterSetName="default")][string] $ReportSubject = "Auswertung", 7 | [Parameter(Mandatory=$false, ParameterSetName="default")][string] $SqlServer = "(local)\NoSpamProxy", 8 | [Parameter(Mandatory=$false, ParameterSetName="default")][string] $SqlInstance = "NoSpamProxy", 9 | [Parameter(Mandatory=$false, ParameterSetName="default")][pscredential] $Credential, 10 | [Parameter(Mandatory=$false, ParameterSetName="default")][pscredential] $SqlCredential, 11 | [Parameter(Mandatory=$false, ParameterSetName="default")][string] $Database = "NoSpamProxyAddressSynchronization", 12 | [Parameter(Mandatory=$false, ParameterSetName="default")][string] $SqlDatabase = "NoSpamProxyAddressSynchronization", 13 | [Parameter(Mandatory=$false, ParameterSetName="default")][bool] $TreatUnkownAsSpam = $true, 14 | [Parameter(Mandatory=$false, ParameterSetName="default")][int] $TopAddressesCount = 10, 15 | [Parameter(Mandatory=$false, ParameterSetName="default")][string[]] $ExcludeFromTopAddresses = @(), 16 | [Parameter(Mandatory=$false, ParameterSetName="default")][int] $TenantId = 0, 17 | # set SqlUser password 18 | [Parameter(Mandatory=$true, ParameterSetName="setLoginPassword")][switch] $SetLoginPassword, 19 | # sql username only used if password is saved in an encrypted binary file 20 | [Parameter(Mandatory = $false, ParameterSetName="default")][string] $SqlUsername, 21 | # locationnof the encrypted binary file for saving a sql password 22 | [Parameter(Mandatory=$false, ParameterSetName="default")][parameter(ParameterSetName = "setLoginPassword")][string] $SqlPasswordFileLocation = "$PSScriptRoot\NspReadSqlPass.bin", 23 | [Parameter(Mandatory=$true, ParameterSetName="getDepreceatedParameters")][switch] $GetDepreceatedParameters 24 | ) 25 | 26 | #--------------------Depreceated handling---------------- 27 | # validate parameters 28 | if ($GetDepreceatedParameters) { 29 | Write-Host "The following parameters are depreceated and will be removed in the future. Please replace them with their new replacements." 30 | Write-Host "" 31 | Write-Host "Database: replaced by `'SqlDatabase`'" 32 | Write-Host "Credential: replaced by `'SqlCredential`'" 33 | Write-Host "SqlServer: is splitted into `'SqlServer`' and `'SqlInstance`', please do not use a combined string anymore." 34 | Write-Host "If you are using the default values for parameters inside the script you do not need to change anything unless you changed those values by yourself." 35 | EXIT 36 | } 37 | $validationExit = $false 38 | if ($PSBoundParameters.ContainsKey('SqlInstance') -AND $SqlServer.Contains("\")){ 39 | Write-Warning "`'-SqlInstance`' cannot be used if the `'SqlServer`' parameter already contains the instance name." 40 | Write-Warning "Please use `'-SqlInstance`' and `'-SqlServer`' together to provider the instance name and the database server through seperate parameters." 41 | Write-Warning "The combined usage is depreceated and will be removed in a future version." 42 | Write-Host 43 | $validationExit = $true 44 | 45 | } 46 | if ($PSBoundParameters.ContainsKey('Database') -AND $PSBoundParameters.ContainsKey('SqlDatabase')){ 47 | Write-Warning "The `'Database`' parameter is depreceated and will be removed in a future version. Please use the `'SqlDatabase`' parameter only." 48 | Write-Host 49 | $validationExit = $true 50 | } 51 | if ($PSBoundParameters.ContainsKey('Credential') -AND $PSBoundParameters.ContainsKey('SqlCredential')){ 52 | Write-Warning "The `'Credential`' parameter is depreceated and will be removed in a future version. Please use the `'SqlCredential`' parameter only." 53 | Write-Host 54 | $validationExit = $true 55 | } 56 | if ($validationExit -eq $true){ 57 | Write-Host "Please fix the above issues and run the script again." 58 | Write-Host "Call `'.\$(Split-Path $PSCommandPath -Leaf) -GetDepreceatedParameters`' to get a list of the desired replacements." 59 | EXIT 60 | } 61 | 62 | #-------------------Functions---------------------- 63 | # create an encrypted binary file which contains the password for the desired SQL user 64 | function Set-loginPass { 65 | # Imports Security library for encryption 66 | Add-Type -AssemblyName System.Security 67 | $sqlPass = Read-Host -Promp 'Input your user password' 68 | $passFileLocation = "$SqlPasswordFileLocation" 69 | $inBytes = [System.Text.Encoding]::Unicode.GetBytes($sqlPass) 70 | $protected = [System.Security.Cryptography.ProtectedData]::Protect($inBytes, $null, [System.Security.Cryptography.DataProtectionScope]::LocalMachine) 71 | [System.IO.File]::WriteAllBytes($passFileLocation, $protected) 72 | } 73 | # return the SQL user password from the encrypted binary file 74 | # if file does not exists give a hint and ask for manual input 75 | function Get-loginPass { 76 | # Imports Security library for encryption 77 | Add-Type -AssemblyName System.Security 78 | Add-Type -AssemblyName System.Text.Encoding 79 | $passFileLocation = "$SqlPasswordFileLocation" 80 | if (Test-Path $passFileLocation) { 81 | try { 82 | $protected = [System.IO.File]::ReadAllBytes($passFileLocation) 83 | $rawKey = [System.Security.Cryptography.ProtectedData]::Unprotect($protected, $null, [System.Security.Cryptography.DataProtectionScope]::LocalMachine) 84 | return [System.Text.Encoding]::Unicode.GetString($rawKey) 85 | } 86 | catch { 87 | Write-Host $_.Exception | format-list -force 88 | } 89 | } 90 | else { 91 | Write-Host "No Password file found! Please run '$($PSCommandPath) -SetLoginPassword' for saving your password encrypted." 92 | $loginPass = Read-Host -Promp 'Input your user password' 93 | return $loginPass 94 | } 95 | } 96 | function sumUp($tmpArray){ 97 | [int]$tmpValue = 0 98 | foreach($value in $tmpArray){ 99 | $tmpValue = $tmpValue + [int]$value 100 | } 101 | return $tmpValue 102 | } 103 | 104 | function New-DatabaseConnection() { 105 | $connectionString = "Server=$SqlServer\$SqlInstance;Database=$SqlDatabase;" 106 | if ($SqlCredential) { 107 | $networkCredential = $SqlCredential.GetNetworkCredential() 108 | $connectionString += "uid=" + $networkCredential.UserName + ";pwd=" + $networkCredential.Password + ";" 109 | } elseif ($SqlUsername) { 110 | $password = (convertto-securestring -string (Get-loginPass) -asplaintext -force) 111 | $Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $SqlUsername, $password 112 | $networkCredential = $Credential.GetNetworkCredential() 113 | $connectionString += "uid=" + $networkCredential.UserName + ";pwd=" + $networkCredential.Password + ";" 114 | } 115 | else { 116 | $connectionString +="Integrated Security=True"; 117 | } 118 | $connection = New-Object System.Data.SqlClient.SqlConnection 119 | $connection.ConnectionString = $connectionString 120 | 121 | $connection.Open() 122 | 123 | return $connection; 124 | } 125 | 126 | function Coalesce-Zero($a) { 127 | if ($a) { $a } else { 0 } 128 | } 129 | 130 | function Invoke-SqlQuery([string] $queryName, [bool] $isInlineQuery = $false, [bool] $isSingleResult) { 131 | try { 132 | $connection = New-DatabaseConnection 133 | $command = $connection.CreateCommand() 134 | if ($isInlineQuery) { 135 | $command.CommandText = $queryName; 136 | } 137 | else { 138 | $command.CommandText = (Get-Content "$queryName.sql") -f $dateFrom, $dateTo, $TenantId 139 | } 140 | if ($isSingleResult) { 141 | return $command.ExecuteScalar(); 142 | } 143 | else { 144 | $result = $command.ExecuteReader() 145 | $table = new-object "System.Data.DataTable" 146 | $table.Load($result) 147 | return $table 148 | } 149 | } 150 | finally { 151 | $connection.Close(); 152 | } 153 | 154 | } 155 | 156 | #-------------------Variables---------------------- 157 | # migrate old variables to new one 158 | if ($PSBoundParameters.ContainsKey('SqlInstance') -AND $PSBoundParameters.ContainsKey('SqlDatabase')) { 159 | Write-Host "It looks like you are using the new parameters." 160 | } elseif ($SetLoginPassword) {} else { 161 | Write-Host "Translating old paramters to new parameters." 162 | Write-Warning "Please adjust your script invocation to match the new parameters. The old ones will be removed in a future version." 163 | Write-Warning "Run `'.\$(Split-Path $PSCommandPath -Leaf) -GetDepreceatedParameters`' to get a list of the desired replacements." 164 | Write-Host "" 165 | $SqlCredential = $Credential 166 | $Credential = $null 167 | if ($SqlServer.Contains("\")){ 168 | $SqlInstance = $SqlServer.Split('\')[1] 169 | $SqlServer = $SqlServer.Split('\')[0] 170 | } else { 171 | if ($PSBoundParameters.ContainsKey('SqlInstance')) { 172 | } else { 173 | Write-Warning "You provided a SQL server but no SQL instance name." 174 | Write-Warning "For compatibility we are trying to use `'NoSpamProxy`' for the connection." 175 | Write-Warning "Please use the `'-SqlInstance`' parameter for your next execution." 176 | } 177 | } 178 | $SqlDatabase = $Database 179 | } 180 | 181 | $reportFileName = [System.IO.Path]::Combine($Env:TEMP, "reject-analysis.html") 182 | $totalRejected = 0 183 | $tempRejected = 0 184 | $permanentRejected = 0 185 | $rblRejected = 0 186 | $cyrenSpamRejected = 0 187 | $cyrenAVRejected = 0 188 | $surblRejected = 0 189 | $characterSetRejected = 0 190 | $wordRejected = 0 191 | $contentrejected = 0 192 | $greylistrejected = 0 193 | $rdnsPermanentRejected = 0 194 | $decryptPolicyRejected = 0 195 | $dateStart = (Get-Date).AddDays(-$NumberOfDaysToReport) 196 | $dateTo = Get-Date -format "dd.MM.yyyy HH:mm:ss" 197 | $dateFrom = $dateStart.ToString("dd.MM.yyyy HH:mm:ss") 198 | 199 | #--------------------Main----------------------- 200 | # create password file for login 201 | if($SetLoginPassword){ 202 | Set-loginPass 203 | EXIT 204 | } 205 | $databaseVersion = [Version] (Invoke-SqlQuery "SELECT value FROM sys.fn_listextendedproperty ('AddressSynchronizationDBVersion', null, null, null, null, null, default)" -isInlineQuery $true -isSingleResult $true) 206 | if ($databaseVersion -gt ([Version] "14.0.0")) { 207 | if ($TenantId -eq 0) { 208 | Write-Host "" 209 | Write-Host "If you are using the provder mode and want to run this script for a specific tenant then you need to provide the desired tenant id using the parameter `'-TenantId`'." 210 | Write-Host "" 211 | } 212 | #$ownDomains = Invoke-SqlQuery "SELECT Name FROM [Configuration].[OwnedDomain] WHERE TenantId = $TenantId" -isInlineQuery $true 213 | "Getting MessageTracks..." 214 | $blockedMessageStatistics = Invoke-SqlQuery "BlockedMessageTracks_v14" 215 | "Getting actions statistics..." 216 | $actions = Invoke-SqlQuery "Actions_v14" 217 | "Getting filter statistics..." 218 | $filters = Invoke-SqlQuery "Filters_v14" 219 | #"Getting Address Counts" 220 | #$addresses = Invoke-SqlQuery "TopAddresses_v14" 221 | #$spammers = Invoke-SqlQuery "TopSpammers_v14" 222 | } else { 223 | if ($databaseVersion -gt ([Version] "11.2.22")) { 224 | $MailsToInvalidRecipients = Invoke-SqlQuery "UnknownRecipients_Current" -isSingleResult $true 225 | } else { 226 | $MailsToInvalidRecipients = Invoke-SqlQuery "UnknownRecipients_Old" -isSingleResult $true 227 | } 228 | #$ownDomains = (Get-NspOwnedDomain).Domain 229 | "Getting MessageTracks..." 230 | $blockedMessageStatistics = Invoke-SqlQuery "BlockedMessageTracks" 231 | "Getting actions statistics..." 232 | $actions = Invoke-SqlQuery "Actions" 233 | "Getting filter statistics..." 234 | $filters = Invoke-SqlQuery "Filters" 235 | #"Getting Address Counts" 236 | #$addresses = Invoke-SqlQuery "TopAddresses" 237 | #$spammers = Invoke-SqlQuery "TopSpammers" 238 | } 239 | 240 | "Getting List of mails to unknown recipients..." 241 | 242 | "Building report." 243 | $totalMails = $blockedMessageStatistics | Where-Object {$_.Direction -eq "Summary" -and $_.Status -eq "Summary"} | Select-Object -ExpandProperty Count -First 1 244 | $tempRejected = $blockedMessageStatistics | Where-Object {$_.Direction -eq "Inbound" -and ($_.Status -eq "Temporary Blocked")} | Select-Object -ExpandProperty Count -First 1 245 | $permanentRejected = $blockedMessageStatistics | Where-Object {$_.Direction -eq "Inbound" -and ($_.Status -eq "Permanently Blocked")} | Select-Object -ExpandProperty Count -First 1 246 | if ($null -eq $tempRejected){ 247 | $tempRejected = 0 248 | } 249 | if ($null -eq $permanentRejected){ 250 | $permanentRejected = 0 251 | } 252 | $totalRejected = $tempRejected + $permanentRejected 253 | $totalRejected += $blockedMessageStatistics | Where-Object {$_.Direction -eq "Inbound" -and ($_.Status -eq "Temporary Blocked")} | Select-Object -ExpandProperty Count -First 1 254 | $inboundmessages = $blockedMessageStatistics | Where-Object {$_.Direction -eq "Inbound" -and $_.Status -eq "Summary"} | Select-Object -ExpandProperty Count -First 1 255 | $outboundmessages = $blockedMessageStatistics | Where-Object {$_.Direction -eq "Outbound" -and $_.Status -eq "Summary"} | Select-Object -ExpandProperty Count -First 1 256 | 257 | $rblRejected = Coalesce-Zero ($filters | Where-Object {$_.Name -eq "realtimeBlocklist" } | Select-Object -ExpandProperty Count -First 1) 258 | $surblRejected = Coalesce-Zero ($filters | Where-Object {$_.Name -eq "surblFilter" } | Select-Object -ExpandProperty Count -First 1) 259 | $cyrenSpamRejected = Coalesce-Zero ($filters | Where-Object {$_.Name -eq "cyrenFilter" } | Select-Object -ExpandProperty Count -First 1) 260 | $cyrenIPRejected = Coalesce-Zero ($filters | Where-Object {$_.Name -eq "cyrenIpReputationFilter" } | Select-Object -ExpandProperty Count -First 1) 261 | $characterSetRejected = Coalesce-Zero ($filters | Where-Object {$_.Name -eq "characterSetFilter" } | Select-Object -ExpandProperty Count -First 1) 262 | $wordRejected = Coalesce-Zero ($filters | Where-Object {$_.Name -eq "wordFilter" } | Select-Object -ExpandProperty Count -First 1) 263 | $rdnsPermanentRejected = Coalesce-Zero ($filters | Where-Object {$_.Name -eq "reputation" } | Select-Object -ExpandProperty Count -First 1) 264 | $cyrenAVRejected = Coalesce-Zero (sumUp ($actions | Where-Object {$_.Name -eq "cyrenAction" } | Select-Object -ExpandProperty Count)) 265 | $contentrejected = Coalesce-Zero (sumUp ($actions | Where-Object {$_.Name -eq "ContentFiltering" } | Select-Object -ExpandProperty Count)) 266 | $decryptPolicyRejected = Coalesce-Zero ($actions | Where-Object {$_.Name -eq "validateSignatureAndDecrypt" } | Select-Object -ExpandProperty Count -First 1) 267 | 268 | <# 269 | This code could enhance the future output of this script. 270 | 271 | $topSpammers = $spammers | Select-Object -first $TopAddressesCount 272 | $topRecipientsOutgoing = ($addresses | ?{$_.AddressType -eq "Recipient" -and $_.Address -notin $ExcludeFromTopAddresses -and $_.Domain -in $ownDomains} | Sort Count -Descending | select -First $TopAddressesCount) 273 | $topSendersOutgoing = ($addresses | ?{$_.AddressType -eq "Sender" -and $_.Address -notin $ExcludeFromTopAddresses -and $_.Domain -in $ownDomains} | Sort Count -Descending | select -First $TopAddressesCount) 274 | $topSendersIncoming = ($addresses | ?{$_.AddressType -eq "Recipient" -and $_.Address -notin $ExcludeFromTopAddresses -and $_.Domain -notin $ownDomains} | Sort Count -Descending | select -First $TopAddressesCount) 275 | $topRecipientsIncoming = ($addresses | ?{$_.AddressType -eq "Sender" -and $_.Address -notin $ExcludeFromTopAddresses -and $_.Domain -notin $ownDomains} | Sort Count -Descending | select -First $TopAddressesCount) 276 | #> 277 | 278 | "Retrieving number of mails with invalid recipients" 279 | if ($TreatUnkownAsSpam) { 280 | $SpamRejected = $totalRejected - $MailsToInvalidRecipients 281 | } 282 | else{ 283 | $SpamRejected = $totalRejected 284 | } 285 | 286 | $mailsprocessed = $totalMails 287 | 288 | if ($inboundmessages -eq 0 -OR $null -eq $inboundmessages) { 289 | $blockedpercentage = 0 290 | $MailsToInvalidRecipientsPercentage = 0 291 | } else { 292 | $blockedpercentage = [Math]::Round($SpamRejected/$inboundmessages*100,2) 293 | $MailsToInvalidRecipientsPercentage = [Math]::Round($MailsToInvalidRecipients/$inboundmessages*100,2) 294 | } 295 | 296 | if ($SpamRejected -eq 0) { 297 | $cyrenspamblockpercentage = 0 298 | $cyrenavblockpercentage = 0 299 | $cyrenIPBlockpercentage = 0 300 | $surblblockedpercentage = 0 301 | $charactersetblockedpercentage = 0 302 | $wordrejectedblockedpercentage = 0 303 | $decryptpolicyblockedpercentage = 0 304 | $rblRejectedpercentage = 0 305 | $reputationFilterRejectedpercentage = 0 306 | $contentrejectedpercentage = 0 307 | $greylistrejectedpercentage = 0 308 | } else { 309 | $cyrenspamblockpercentage = [Math]::Round($cyrenSpamRejected/$SpamRejected*100,2) 310 | $cyrenavblockpercentage = [Math]::Round($cyrenAVRejected/$SpamRejected*100,2) 311 | $cyrenIPBlockpercentage = [Math]::Round($cyrenIPRejected/$SpamRejected*100,2) 312 | $surblblockedpercentage = [Math]::Round($surblRejected/$SpamRejected*100,2) 313 | $charactersetblockedpercentage = [Math]::Round($characterSetRejected/$SpamRejected*100,2) 314 | $wordrejectedblockedpercentage = [Math]::Round($wordRejected/$SpamRejected*100,2) 315 | $decryptpolicyblockedpercentage = [Math]::Round($decryptPolicyRejected/$SpamRejected*100,2) 316 | $rblRejectedpercentage = [Math]::Round($rblRejected/$SpamRejected*100,2) 317 | $reputationFilterRejectedpercentage = [Math]::Round($rdnsPermanentRejected/$SpamRejected*100,2) 318 | $contentrejectedpercentage = [Math]::Round($contentRejected/$SpamRejected*100,2) 319 | $greylistrejectedpercentage = [Math]::Round($greylistRejected/$SpamRejected*100,2) 320 | } 321 | 322 | 323 | Write-Host " " 324 | Write-Host "TemporaryReject Total:" $tempRejected 325 | Write-Host "PermanentReject Total:" $permanentRejected 326 | Write-Host "TotalReject:" $totalRejected 327 | Write-Host "Unknown recipients": $MailsToInvalidRecipients 328 | Write-Host " " 329 | Write-Host "Sending E-Mail to " $ReportRecipient "..." 330 | 331 | $global:htmlout = " 332 | 333 | Auswertung der abgewiesenen E-Mails 334 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 |
"+ $dateFrom +" bis "+ $dateTo +" ("+$NumberOfDaysToReport+" Tage)CountPercent
Mails Processed" + $mailsprocessed +" 
Sent" + $outboundmessages +" 
Received" + $inboundmessages +" 
Mails to invalid recipients" + $MailsToInvalidRecipients +"" + $MailsToInvalidRecipientsPercentage + " %
Mails blocked due to Spam, Virus or Policy violation" + $SpamRejected +"" + $blockedpercentage +" %
Realtime Blocklist Check" + $rblRejected +"" + $rblRejectedpercentage +" %
Reputation Check" + $rdnsPermanentRejected +"" + $reputationFilterRejectedpercentage +" %
Cyren IP Reputation" + $cyrenIPRejected +"" + $cyrenIPBlockpercentage +" %
Cyren AntiSpam" + $cyrenSpamRejected +"" + $cyrenspamblockpercentage +" %
Cyren AntiVirus" + $cyrenAVRejected +"" + $cyrenavblockpercentage +" %
Spam URI Realtime Blocklists" + $surblRejected +"" + $surblblockedpercentage +" %
Allowed Unicode Character Sets" + $characterSetRejected +"" + $charactersetblockedpercentage +" %
Word Matching" + $wordRejected +"" + $wordrejectedblockedpercentage +" %
DecryptPolicy Reject" + $decryptPolicyRejected +"" + $decryptpolicyblockedpercentage +" %
ContentFiltering" + $contentrejected + "" + $contentrejectedpercentage + " %
Greylisting" + $greylistrejected + "" + $greylistrejectedpercentage + " %
369 | 370 | " 371 | 372 | 373 | 374 | 375 | $htmlout | Out-File $reportFileName 376 | "Sending report to $ReportRecipient" 377 | Send-MailMessage -SmtpServer $SmtpHost -From $ReportSender -To $ReportRecipient -Subject $ReportSubject -Body "Im Anhang dieser E-Mail finden Sie den Bericht mit der Auswertung der abgewiesenen E-Mails." -Attachments $reportFileName 378 | Write-Host "Doing some cleanup.." 379 | Remove-Item $reportFileName 380 | Write-Host "Done." 381 | --------------------------------------------------------------------------------