Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Email Notification when server is logged into remotely.

Posted on 2007-11-19
15
Medium Priority
?
533 Views
Last Modified: 2010-04-21
I am wondering if there is a software package out there that would sent an admin and email everytime one of the servers in in environment has been accessed via Terminal Services. I would like to be notified whenever anyone logges directly into the server.
0
Comment
Question by:jlycos1
  • 10
  • 5
15 Comments
 
LVL 5

Expert Comment

by:JohnDemerjian
ID: 20314957
don't know if there is a third party package, but you could create a login script that simply sends you an email when it runs.  that way whenever anyone logs onto the server either locally or remotely the script will run and send you an email.  
0
 
LVL 5

Expert Comment

by:JohnDemerjian
ID: 20315011
here is a vbscript that will send an email.  run it from a batch file with the command "cscript email.vbs" assuming you call the file email.vbs
Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = "This is the subject of the email" 
objMessage.Sender = "your_name@company.com" 
objMessage.To = "john_jones@company.com, joe.smith@company.com"
objMessage.TextBody = "The network is down, but I'm feeling better."
 
'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
 
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
 
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.company.com"
 
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
 
objMessage.Configuration.Fields.Update
 
'==End remote SMTP server configuration section==
 
objMessage.Send 
Open in New Window 

Open in new window

0
 
LVL 1

Author Comment

by:jlycos1
ID: 20315956
Is there a way to let you know who they logged in as.
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
LVL 1

Author Comment

by:jlycos1
ID: 20315972
Can I place this is the startup folder....
0
 
LVL 5

Expert Comment

by:JohnDemerjian
ID: 20316047
i'm sure you could get the user name into the email somehow, but you'd need to poke around on the net.  you wouldn't need to place it in a startup folder if you made an OU for the servers, put a GP in place and then ran this as a login script on the OU.  that's one way to do it anyway.  here's a post that may help capture that user name.  a sloppy way (what i would probably do) is to have %username% dumped into a text file and then attach that file to the email and send.  this is very sloppy from a programatical sense but it would work if you are not able to piece together the exact script you want.
0
 
LVL 1

Author Comment

by:jlycos1
ID: 20316166
I have the vbs with my email as the sender and reciever with the exchnage server name as the smtp server and still no emails to my inbox. I am just executing the vbs using th cmd prompt  with the location of c: for testing.
0
 
LVL 1

Author Comment

by:jlycos1
ID: 20316176
I removed Open in New Window from the script because I was receiving a syntax issue on line 26.
0
 
LVL 1

Author Comment

by:jlycos1
ID: 20316245
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "DC Has been Logged Into"
objMessage.Sender = "BlaBla@mydmain.com"
objMessage.To = "blabla@mydomain.com"
objMessage.TextBody = "Someone logged into DC"
 
'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
 
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
 
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "exchange1"
 
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
 
objMessage.Configuration.Fields.Update
 
'==End remote SMTP server configuration section==
 
objMessage.Send
0
 
LVL 1

Author Comment

by:jlycos1
ID: 20319818
Whenever I enter the command cscript email.vbs on the root of c: and hit enter I get a little symantec window in the lower left letting me know that it "Scanning Message 1 of 1" but I do not see it in my email. Anyhelp would be helpful.
0
 
LVL 5

Accepted Solution

by:
JohnDemerjian earned 1000 total points
ID: 20319979
The orignal script is working fine and you should disable the symantec app that is causing a problem temporarily.  Also, your Exchange server may need you to add the IP address of the servers that are trying to run the script into the list of servers allowed to relay.  Finally, the attached script adds the user name and computer name to the text of the message...
Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = "DC Has been Logged Into" 
objMessage.Sender = "jdemerjian@company.com" 
objMessage.From = "John Demerjian"
objMessage.To = "jdemerjian@company.com"
Set wshShell = WScript.CreateObject( "WScript.Shell" )
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
strUserName = wshShell.ExpandEnvironmentStrings( "%USERNAME%" )
objMessage.TextBody = strUserName & " logged into DC " & strComputerName
 
'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
 
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
 
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.company.com"
 
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
 
objMessage.Configuration.Fields.Update
 
'==End remote SMTP server configuration section==
 
objMessage.Send

Open in new window

0
 
LVL 1

Author Comment

by:jlycos1
ID: 20320249
I have it working now with the script below:

' ------ SCRIPT CONFIGURATION ------
strFrom = "bla@bla.com"
strTo = "bla@bla.com"
strSub = "Backup Has been Logged Into"
strBody = "Someone logged into Backup"
strSMTP = "smtp.bla.com"
' ------ END CONFIGURATION ---------
set objEmail = CreateObject("CDO.Message")
objEmail.From = strFrom
objEmail.To = strTo
objEmail.Subject = strSub
objEmail.Textbody = strBody
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "10.0.0.110"
objEmail.Configuration.Fields.Update
objEmail.Send
WScript.Echo "Email sent"

You had mentioned a sloppy way to include the name of the user that logged in, where did nyou find that?
0
 
LVL 5

Expert Comment

by:JohnDemerjian
ID: 20320400
cool, i'm glad it works.  actually i put a clean way together.  see the post above, but the text you are interested in is:


Set wshShell = WScript.CreateObject( "WScript.Shell" )
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
strUserName = wshShell.ExpandEnvironmentStrings( "%USERNAME%" )
objMessage.TextBody = strUserName & " logged into DC " & strComputerName

Open in new window

0
 
LVL 1

Author Comment

by:jlycos1
ID: 20321214
Where would this username portion be placed within the script?
0
 
LVL 1

Author Comment

by:jlycos1
ID: 20321313
Sorry I see the post above.....Works perfect......
0
 
LVL 1

Author Closing Comment

by:jlycos1
ID: 31409973
Great Script.....Everyone should use.....
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us need to configure DHCP server(s) in their environment. We can do that simply via DHCP console on server or using MMC snap-in on each computer with Administrative Tools installed in a network. But what if we have to configure many DHCP ser…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question