ESET Online Help

Search English
Select the topic

Sample PowerShell scripts

Below are two sample PowerShell scripts to be used for delivering OTP via custom email solution (application).

PowerShell script using Send-MailMessage - we name the file as sendmail.ps1

PowerShell script using System.Net.Mail - we name the file as sendmail.ps1

 


note

Replace the placeholders

In the sample scripts above, replace the <server>, <port>, <username> and <password> placeholders with the corresponding SMTP details.

Test and use

1.Save the script in a desired location, for example c:\work\sendmail.ps1

2.Test the script outside of ESET Secure Authentication On-Prem (ESA) using Windows command line:

a.Press Windows key + R key combination.

b.Type cmd.EXE, press Enter.

c.In the command line window, execute:

powershell c:\scripts\sendmail.ps1 test@address.com 123456

while test@address.com is supposed to be replaced with a valid email address, you can read its inbox.

d.If the test is successful, proceed with the next step.

3.In the Delivery Options section of ESA, refer to the script this way:

powershell c:\scripts\sendmail.ps1 [E-mail-Addresses] [OTP]