Solved

Email Notification when server is logged into remotely.

Posted on 2007-11-19
15
519 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
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 250 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Server Login Issue 4 73
Screen Mirroring 7 113
How to decline Windows updates with SCCM? 2 84
Adding 2008 R2 server to 2003 domain:  2003 DC to 2008 R2 DC 6 45
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

710 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