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.
LVL 1
the_omnificAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mal OsborneAlpha GeekCommented:
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.
Mal OsborneAlpha GeekCommented:
echo Log In %Date% %TIME% %USERNAME% >> \\someserver\someshare\logins.txt

Should do it. Maybe add some commas if you plan to throw into an Excel spreadsheet.

You can also assign a logoff script, appending the same file, or a separate one.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
the_omnificAuthor Commented:
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 OsborneAlpha GeekCommented:
Only assign the script to accounts you would like to monitor.
Bob McCoyCommented:
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

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.