• RSS
  • Twitter
  • FaceBook

Welcome to ISAserver.org

Forums | Register | Login | My Profile | Inbox | RSS RSS icon | My Subscription | My Forums | Address Book | Member List | Search | FAQ | Ticket List | Log Out

VPN Connect/Disconnect Script

Users viewing this topic: none

Logged in as: Guest
  Printable Version
All Forums >> [ISA 2006 Misc.] >> ISA Firewall Tools >> VPN Connect/Disconnect Script Page: [1]
Login
Message << Older Topic   Newer Topic >>
VPN Connect/Disconnect Script - 25.Apr.2007 4:27:40 PM   
JBakels

 

Posts: 78
Joined: 4.Jan.2002
From: Bradenton, FL USA
Status: offline
Here are two scripts you can run (or combine and run) to notify you if a VPN connection is made.
---
'VPN Connected Script
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate, (Security)}!\\" & _
       strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _   
   ("Select * from __instancecreationevent where " _
       & "TargetInstance isa 'Win32_NTLogEvent' " _
           & "and TargetInstance.EventCode = '20200' ")
Do
Set objLatestEvent = colMonitoredEvents.NextEvent
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "[email=myISA-alerts@mydomain.com]myISA-alerts@mydomain.com[/email]"
objEmail.To = [email=myISA-alerts@mydomain.com]myISA-alerts@mydomain.com[/email]
objEmail.Subject = "VPN Connection made"
objEmail.Textbody = objLatestEvent.TargetInstance.Message
objEmail.Configuration.Fields.Item _
   ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
   ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
       "exchange.mydomain.com"
objEmail.Configuration.Fields.Item _
   ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
Loop
---
'VPN Disconnected Script
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate, (Security)}!\\" & _
       strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _   
   ("Select * from __instancecreationevent where " _
       & "TargetInstance isa 'Win32_NTLogEvent' " _
           & "and TargetInstance.EventCode = '20194' ")
Do
Set objLatestEvent = colMonitoredEvents.NextEvent
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "[email=myISA-alerts@mydomain.com]myISA-alerts@mydomain.com[/email]"
objEmail.To = "[email=myISA-alerts@mydomain.com]myISA-alerts@mydomain.com[/email]"
objEmail.Subject = "VPN Connection disconnected"
objEmail.Textbody = objLatestEvent.TargetInstance.Message
objEmail.Configuration.Fields.Item _
   ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
   ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
       "exchange.mydomain.com"
objEmail.Configuration.Fields.Item _
   ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
Loop
Post #: 1
RE: VPN Connect/Disconnect Script - 25.Apr.2007 4:43:29 PM   
elmajdal

 

Posts: 6022
Joined: 16.Sep.2004
From: Lebanese in Kuwait
Status: offline
Can you provide a short explanation of what each script does ??

a sample output would be helpfull.

As you know , not all of us are into scripting

_____________________________

Tarek Majdalani

Windows Expert - IT Pro MVP
Facebook : https://www.facebook.com/ElMajdal.Net

(in reply to JBakels)
Post #: 2

Page:   [1] << Older Topic    Newer Topic >>
All Forums >> [ISA 2006 Misc.] >> ISA Firewall Tools >> VPN Connect/Disconnect Script Page: [1]
Jump to:

New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts