Solved

Email Notification when server is logged into remotely.

Posted on 2007-11-19
15
494 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reduce vmdk file & unallocated windows partion 12 79
Domain Share problems 5 54
SolarWind and DNS Server 12 78
What is this Task? 4 111
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…
Scenerio: You have a server running Server 2003 and have applied a retail pack of Terminal Server Licenses.  You want to change servers or your server has crashed and you need to reapply the Terminal Server Licenses. When you enter the 16-digit lic…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

776 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