Jump to content

Recommended Posts

Posted

Add a step to execute a powershell script and then run a script coded as needed maybe? I use this in a script that runs from DCs to alert on user account lock out:

# Email sent from this address (built with constructor so we can specify display name: new-object System.Net.Mail.MailAddress("Email Address", "Display Name")
$emailFrom = new-object System.Net.Mail.MailAddress("$env:[email protected]".ToLower(), "$((Get-Culture).TextInfo.ToTitleCase($env:COMPUTERNAME.ToLower())) - User Account Locked")

# Email sent to this address
$emailTo = "[email protected]"

# Email subject
$emailSubject = "$($event.username) User Account Locked out"

# Email body (converts the event harvested to HTML)
$emailBody = $event | ConvertTo-Html -PreContent "$($event.username) is locked in Active Directory" | Out-String

# SMTP server to proccess the email
$smtpSrv = "domain.mail.protection.outlook.com"

# SMTP Server port
$smtpPort = 25

#send email populated from the above variables
Send-MailMessage -From $emailFrom -To $emailTo -Subject $emailSubject -Body $emailBody -BodyAsHtml -SmtpServer $smtpSrv -Port $smtpPort

 

What I'm really saying is it might be worth looking into the PowerShell cmdlet: Send-MailMessage

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...