Notification when someone login locally or remotely to the server

Math Tec
Math Tec used Ask the Experts™

We have windows server 2008R2. Is there any way that the server sends an email with login details (IP address, location,...etc) when someone login locally or remotely to the server? Or is there any application can do that if this is not doable in server features?

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Rated Freelancer on MS Technologies
Awarded 2018
Distinguished Expert 2018
It's a way with a script something like this

Here's something similar...
And not, is not doable using server features

And it should be configured on the Active Directory GPO object in the Login/Login scripts feature


$IP =(Test-Connection -ComputerName $computer -Count 1  | Select -ExpandProperty IPV4Address | select -ExpandProperty IPAddressToString)

if ($userName -eq $null) { 
#Function to query the remote computer 
Function queryComputer($computer) { 
    $restartReg = $false 
    ping -n 1 $computer | out-null 
    if ($? -eq $false) { 
        echo "Computer not online. Quitting" 

Open in new window

Sending an email whenever someone logs in will require some heave scripting. You can; however, use the Get-EventLog cmdlet to return  all login and logoff events for the server. Here is a guide on how to do this:
How to check event logs with PowerShell

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial