Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Windows Server » microsoft.public.windows.server.scripting
Thread: help combine three scripts to create a log server

HTVi
TV Discussion Newsgroups

help combine three scripts to create a log server
Costas Markou 7/4/2007 1:04:00 PM
i have found three scripts and i need to combine them.

1. I used this script to create a custom event log on a server. OK!

Const NO_VALUE = Empty

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegWrite _
"HKLM\System\CurrentControlSet\Services\EventLog\SecurityCollector\",
NO_VALUE

2. Monitor the Event Logs for the Occurrence of a Specific Event.??

strComputer = "."

Set objWMIService = GetObject("winmgmts:{(Security)}\\" & strComputer &
"\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("Select * from __InstanceCreationEvent Where " _
& "TargetInstance ISA 'Win32_NTLogEvent' " _
& "and TargetInstance.EventCode = '0' ")

Do
Set objLatestEvent = colMonitoredEvents.NextEvent
Wscript.Echo objLatestEvent.TargetInstance.User
Wscript.Echo objLatestEvent.TargetInstance.TimeWritten
Wscript.Echo objLatestEvent.TargetInstance.Message
Wscript.Echo
Loop

3. the following script Write Events to a Remote Event Log.

Const EVENT_SUCCESS = 0

Set objShell = Wscript.CreateObject("Wscript.Shell")

objShell.LogEvent EVENT_SUCCESS, _
"Payroll application successfully installed." , "\\PrimaryServer"

Re: help combine three scripts to create a log server
"Al Dunbar" <AlanDrub[ at ]hotmail.com.nospaam> 7/5/2007 3:47:54 AM

"Costas Markou" <CostasMarkou[ at ]discussions.microsoft.com> wrote in message
news:EC2323B9-5A0B-4FE0-B4A1-CF4EB968ACD8[ at ]microsoft.com...
[Quoted Text]
>i have found three scripts and i need to combine them.
>
> 1. I used this script to create a custom event log on a server. OK!
>
> Const NO_VALUE = Empty
>
> Set WshShell = WScript.CreateObject("WScript.Shell")
> WshShell.RegWrite _
> "HKLM\System\CurrentControlSet\Services\EventLog\SecurityCollector\",
> NO_VALUE
>
> 2. Monitor the Event Logs for the Occurrence of a Specific Event.??
>
> strComputer = "."
>
> Set objWMIService = GetObject("winmgmts:{(Security)}\\" & strComputer &
> "\root\cimv2")
>
> Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
> ("Select * from __InstanceCreationEvent Where " _
> & "TargetInstance ISA 'Win32_NTLogEvent' " _
> & "and TargetInstance.EventCode = '0' ")
>
> Do
> Set objLatestEvent = colMonitoredEvents.NextEvent
> Wscript.Echo objLatestEvent.TargetInstance.User
> Wscript.Echo objLatestEvent.TargetInstance.TimeWritten
> Wscript.Echo objLatestEvent.TargetInstance.Message
> Wscript.Echo
> Loop
>
> 3. the following script Write Events to a Remote Event Log.
>
> Const EVENT_SUCCESS = 0
>
> Set objShell = Wscript.CreateObject("Wscript.Shell")
>
> objShell.LogEvent EVENT_SUCCESS, _
> "Payroll application successfully installed." , "\\PrimaryServer"

Well, you could just cut and paste these scripts into a single file (much as
you have already done to post them). However, it seems to me that the second
script contains an infinite loop, so it would never pass control on to
script chunk number three.


/Al


Re: help combine three scripts to create a log server
Costas Markou 7/5/2007 7:50:00 AM


"Al Dunbar" wrote:

[Quoted Text]
>
> "Costas Markou" <CostasMarkou[ at ]discussions.microsoft.com> wrote in message
> news:EC2323B9-5A0B-4FE0-B4A1-CF4EB968ACD8[ at ]microsoft.com...
> >i have found three scripts and i need to combine them.
> >
> > 1. I used this script to create a custom event log on a server. OK!
> >
> > Const NO_VALUE = Empty
> >
> > Set WshShell = WScript.CreateObject("WScript.Shell")
> > WshShell.RegWrite _
> > "HKLM\System\CurrentControlSet\Services\EventLog\SecurityCollector\",
> > NO_VALUE
> >
> > 2. Monitor the Event Logs for the Occurrence of a Specific Event.??
> >
> > strComputer = "."
> >
> > Set objWMIService = GetObject("winmgmts:{(Security)}\\" & strComputer &
> > "\root\cimv2")
> >
> > Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
> > ("Select * from __InstanceCreationEvent Where " _
> > & "TargetInstance ISA 'Win32_NTLogEvent' " _
> > & "and TargetInstance.EventCode = '0' ")
> >
> > Do
> > Set objLatestEvent = colMonitoredEvents.NextEvent
> > Wscript.Echo objLatestEvent.TargetInstance.User
> > Wscript.Echo objLatestEvent.TargetInstance.TimeWritten
> > Wscript.Echo objLatestEvent.TargetInstance.Message
> > Wscript.Echo
> > Loop
> >
> > 3. the following script Write Events to a Remote Event Log.
> >
> > Const EVENT_SUCCESS = 0
> >
> > Set objShell = Wscript.CreateObject("Wscript.Shell")
> >
> > objShell.LogEvent EVENT_SUCCESS, _
> > "Payroll application successfully installed." , "\\PrimaryServer"
>
> Well, you could just cut and paste these scripts into a single file (much as
> you have already done to post them). However, it seems to me that the second
> script contains an infinite loop, so it would never pass control on to
> script chunk number three.
>
>
> /Al
>
>
>
1.The first script runs only once and creates a custom log on a server.
2.The second script is combined with the third one. The third script is
placed inside DO <> LOOP of the second script and runs on client computers
and writes to the remote event log (application log) on the server.
3.first of all, if i make the combination of the two scripts will they work?
4.second, how do i write events to a remote computer log but choose to which
log to write to.
Re: help combine three scripts to create a log server
Costas Markou 7/5/2007 7:52:02 AM


"Al Dunbar" wrote:

[Quoted Text]
>
> "Costas Markou" <CostasMarkou[ at ]discussions.microsoft.com> wrote in message
> news:EC2323B9-5A0B-4FE0-B4A1-CF4EB968ACD8[ at ]microsoft.com...
> >i have found three scripts and i need to combine them.
> >
> > 1. I used this script to create a custom event log on a server. OK!
> >
> > Const NO_VALUE = Empty
> >
> > Set WshShell = WScript.CreateObject("WScript.Shell")
> > WshShell.RegWrite _
> > "HKLM\System\CurrentControlSet\Services\EventLog\SecurityCollector\",
> > NO_VALUE
> >
> > 2. Monitor the Event Logs for the Occurrence of a Specific Event.??
> >
> > strComputer = "."
> >
> > Set objWMIService = GetObject("winmgmts:{(Security)}\\" & strComputer &
> > "\root\cimv2")
> >
> > Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
> > ("Select * from __InstanceCreationEvent Where " _
> > & "TargetInstance ISA 'Win32_NTLogEvent' " _
> > & "and TargetInstance.EventCode = '0' ")
> >
> > Do
> > Set objLatestEvent = colMonitoredEvents.NextEvent
> > Wscript.Echo objLatestEvent.TargetInstance.User
> > Wscript.Echo objLatestEvent.TargetInstance.TimeWritten
> > Wscript.Echo objLatestEvent.TargetInstance.Message
> > Wscript.Echo
> > Loop
> >
> > 3. the following script Write Events to a Remote Event Log.
> >
> > Const EVENT_SUCCESS = 0
> >
> > Set objShell = Wscript.CreateObject("Wscript.Shell")
> >
> > objShell.LogEvent EVENT_SUCCESS, _
> > "Payroll application successfully installed." , "\\PrimaryServer"
>
> Well, you could just cut and paste these scripts into a single file (much as
> you have already done to post them). However, it seems to me that the second
> script contains an infinite loop, so it would never pass control on to
> script chunk number three.
>
>
> /Al
>
>
>
1.The first script runs only once and creates a custom log on a server.

2.The second script is combined with the third one. The third script is
placed inside DO <> LOOP of the second script and runs on client computers
and writes to the remote event log (application log) on the server.

3.first of all, if i make the combination of the two scripts, will they work?

4.second, how do i write events to a remote computer log but choose to which
log to write to.


Re: help combine three scripts to create a log server
"Al Dunbar" <AlanDrub[ at ]hotmail.com.nospaam> 7/5/2007 1:17:32 PM

"Costas Markou" <CostasMarkou[ at ]discussions.microsoft.com> wrote in message
news:575F85BE-2350-4DD6-8406-23CB9D5BF1FE[ at ]microsoft.com...
[Quoted Text]
>
>
> "Al Dunbar" wrote:
>
>>
>> "Costas Markou" <CostasMarkou[ at ]discussions.microsoft.com> wrote in message
>> news:EC2323B9-5A0B-4FE0-B4A1-CF4EB968ACD8[ at ]microsoft.com...
>> >i have found three scripts and i need to combine them.
>> >
>> > 1. I used this script to create a custom event log on a server. OK!
>> >
>> > Const NO_VALUE = Empty
>> >
>> > Set WshShell = WScript.CreateObject("WScript.Shell")
>> > WshShell.RegWrite _
>> >
>> > "HKLM\System\CurrentControlSet\Services\EventLog\SecurityCollector\",
>> > NO_VALUE
>> >
>> > 2. Monitor the Event Logs for the Occurrence of a Specific Event.??
>> >
>> > strComputer = "."
>> >
>> > Set objWMIService = GetObject("winmgmts:{(Security)}\\" & strComputer &
>> > "\root\cimv2")
>> >
>> > Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
>> > ("Select * from __InstanceCreationEvent Where " _
>> > & "TargetInstance ISA 'Win32_NTLogEvent' " _
>> > & "and TargetInstance.EventCode = '0' ")
>> >
>> > Do
>> > Set objLatestEvent = colMonitoredEvents.NextEvent
>> > Wscript.Echo objLatestEvent.TargetInstance.User
>> > Wscript.Echo objLatestEvent.TargetInstance.TimeWritten
>> > Wscript.Echo objLatestEvent.TargetInstance.Message
>> > Wscript.Echo
>> > Loop
>> >
>> > 3. the following script Write Events to a Remote Event Log.
>> >
>> > Const EVENT_SUCCESS = 0
>> >
>> > Set objShell = Wscript.CreateObject("Wscript.Shell")
>> >
>> > objShell.LogEvent EVENT_SUCCESS, _
>> > "Payroll application successfully installed." , "\\PrimaryServer"
>>
>> Well, you could just cut and paste these scripts into a single file (much
>> as
>> you have already done to post them). However, it seems to me that the
>> second
>> script contains an infinite loop, so it would never pass control on to
>> script chunk number three.
>>
>>
>> /Al
>>
>>
>>
> 1.The first script runs only once and creates a custom log on a server.
> 2.The second script is combined with the third one. The third script is
> placed inside DO <> LOOP of the second script and runs on client computers
> and writes to the remote event log (application log) on the server.
> 3.first of all, if i make the combination of the two scripts will they
> work?

Have you not just tried it to see what happens? Although problems can result
from sticking unrelated bits of script together rather than designing the
new script properly, I don't see any obvious issues with the scripts as you
have shown them.

> 4.second, how do i write events to a remote computer log but choose to
> which
> log to write to.

I don't know off hand. Which log receives the log entry created by script
number 3?

/Al


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen