Notify via Email on user login with Public IP with Event ID 21 Using PowerShell script
PowerShell script for Windows Server. This script is used for fire and Email notification on any user login via Public IP. Steps: 1. Save the script with the name EmailNotification.ps1. 2. Create a Basic Task via Task Scheduler. Enter Name for Task. 3. Select the Trigger option "When a specific event is logged" 4. Select option as below. 5. On Action Select "Start a specific program" and browse the EmailNotification.ps1 file. 6. Save the task. Script: # Define the SMTP server details and user credentials $smtpServer = "SMTP server" # SMTP.GMAIL.COM $smtpUsername = "SMTP username" $smtpPassword = "password for authentication" $smtpSecurePassword = ConvertTo-SecureString -String $smtpPassword -AsPlainText -Force $smtpCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $smtpUsername, $smtpSecurePassword $from = "from@example.com" $to = "to@example.com" # Define Regex ...