Skip to content

Instantly share code, notes, and snippets.

@PatrickTerlisten
Created February 6, 2022 10:42
Show Gist options
  • Save PatrickTerlisten/7dfb9ef4477eece43eb34fefba701b1a to your computer and use it in GitHub Desktop.
Save PatrickTerlisten/7dfb9ef4477eece43eb34fefba701b1a to your computer and use it in GitHub Desktop.
E-Mail notification for new member in domain-global group
#Get events
$Event = Get-EventLog -LogName Security -InstanceId 4728 -Newest 1
#get some details
$User = $Event.ReplacementStrings[0]
$Antragsteller = $Event.ReplacementStrings[6]
$Gruppe = $Event.ReplacementStrings[2]
# smtp server
$emailSmtpServer = "mailserver.domain.tld"
# recipient
$emailFrom= "[email protected]"
$emailTo = "[email protected]", "[email protected]"
$subject = "Neuer Benutzer in domänen-globaler Gruppe: " + $Gruppe + "\" + $User
$body = "Gruppe\Benutzername: " + $Gruppe + "\" + $User + "`r`n" + "Antragsteller: " + $Antragsteller + "`r`n" + "Time: " + $Event.TimeGenerated + "`r`n"
Send-MailMessage -SmtpServer $emailSmtpServer -From $emailFrom -To $emailTo -Subjec $subject -Body $body -BodyAsHtml -Encoding UTF8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment