Avatar of Carl Billington
Carl Billington
Flag for Australia asked on

Record and send email when a user logs on to a server using a Domain Admin account

Is it possible to send an email notification when a user logs on using a Domain Admin account? Or at the very least record the name, computer and date/time stamp and email this information a specific email address at the end of the week?
   
The environment consists of Windows 2003-2012 RS servers.
 
Thank you.
PowershellShell ScriptingActive Directory

Avatar of undefined
Last Comment
Bob McCoy

8/22/2022 - Mon
Mal Osborne

Yep, pretty easy.

Just assign a login script in ADUC, and have it do whatever. A common config is to just append username and time to a text file on the network.
ASKER CERTIFIED SOLUTION
Mal Osborne

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Carl Billington

ASKER
But this will log all user logons. I only want to record Domain Admins. I do not need to record Network Administrators etc.
 
Let me know your thoughts.
Mal Osborne

Only assign the script to accounts you would like to monitor.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Bob McCoy

It's a matter of determining if the user is in the Administrators role as part of the login script.

$windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$windowsPrincipal = new-object 'System.Security.Principal.WindowsPrincipal' $windowsIdentity

if ($windowsPrincipal.IsInRole("Administrators"))
{
    # Put your email logic here.
}

Open in new window