Some notes:
- To use STARTTLS apply this change:
Function Send-CertificateList
{
#initialize email pre-reqs
$FromAddress = 'emailaddress@domainname.com'
$ToAddress = 'emailaddress@domainname.com'
$MessageSubject = "Certificate expiration reminder from $env:COMPUTERNAME.$env:USERDNSDOMAIN"
$SendingServer = 'Mail server'
$SmtpServerPort = "Port number"
[System.Net.ServicePointManager]::SecurityProtocol = 'TLS12'
#Test if SMTP server is responding
if(Test-Connection -Cn $SendingServer -BufferSize 16 -Count 1 -ea 0 -quiet){
#Send email
Send-MailMessage -From $FromAddress -To $ToAddress -Subject $MessageSubject -Body $mailbody -BodyAsHtml -SmtpServer $SendingServer -Port $SmtpServerPort -UseSsl
}else{
#Error Handling
write-host -object 'No connection to SMTP server. Failed to send email!'
}
}
Function Send-Certificatemail
{
#initialize email pre-reqs
$FromAddress = 'emailaddress@domainname.com'
$MessageSubject = "Certificate expiration reminder from $env:COMPUTERNAME.$env:USERDNSDOMAIN"
$SendingServer = 'Mail server'
$SmtpServerPort = "Port number"
[System.Net.ServicePointManager]::SecurityProtocol = 'TLS12'
#Test if SMTP server is responding
if(Test-Connection -Cn $SendingServer -BufferSize 16 -Count 1 -ea 0 -quiet){
#Send email
Send-MailMessage -From $FromAddress -To $ToAddress -Cc $CCAddress -Subject $MessageSubject -Body $Emailbody -BodyAsHtml -SmtpServer $SendingServer -Port $SmtpServerPort -UseSsl
}else{
#Error Handling
write-host -object 'No connection to SMTP server. Failed to send email!'
}
}
- To check all the certificates and templates, comment out all lines which include the filterlist variable.
That's all!