Solved

Reduce script output  (need code to give count of duplicates and only view 1)

Posted on 2008-06-17
14
947 Views
Last Modified: 2011-10-19
Thanks to purplepomegranite  i have a script to check the eventviewer till 2 weeks ago.(thanks again for that!) Now i need to go further, i need to filter duplicates ( Example error 435 on SERVICES is placed 30 times in the eventviewer) I'd like to see only 1 but with a count of duplicates.

I have tried some stuff with if count>1, but with my noobieness i just can't figger it out.. any help?  
' Set earliest time for events that we want

Set objSWbemDateTime = CreateObject("WbemScripting.SWbemDateTime")

objSWbemDateTime.SetVarDate FormatDateTime(DateAdd("D",-14,Now),2), true

' The -14 specifies up to 14 days ago... change as appropriate

 

strHTML = strHTML & VbCrLf & "<br><br><b>Logboeken FOUTEN:</b><br>"

 

strComputer="."

Set objWMIService = GetObject("winmgmts:" _

    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

 

Set colLoggedEvents = objWMIService.ExecQuery _

    ("Select * from Win32_NTLogEvent Where Logfile = 'System'" _

        & " and EventType = '1' and TimeWritten>='" & objSWbemDateTime.Value & "'")

 

		

For Each objEvent in colLoggedEvents

 

    strHTML = strHTML & VbCrLf & "<br>Event Code: " & objEvent.EventCode

    strHTML = strHTML & VbCrLf & "<br>Doelbestand: " & objEvent.SourceName    

    strHTML = strHTML & VbCrLf & "<br>Bericht: " & objEvent.Message

    strHTML = strHTML & VbCrLf & "<br>Tijd geschreven: " & objEvent.TimeWritten

    strHTML = strHTML & VbCrLf & "<br>Type: " & objEvent.Type

    strHTML = strHTML & VbCrLf & "<br><br>"

 

Next	

 

strHTML = strHTML & VbCrLf & "<br><br><b>Logboeken WAARSCHUWINGEN:</b><br>"

 

 

Set objWMIService = GetObject("winmgmts:" _

    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

 

Set colLoggedEvents = objWMIService.ExecQuery _

    ("Select * from Win32_NTLogEvent Where Logfile = 'System'" _

        & " and EventType = '2' and TimeWritten>='" & objSWbemDateTime.Value & "'")

 

For Each objEvent in colLoggedEvents

 

    strHTML = strHTML & VbCrLf & "<br>Event Code: " & objEvent.EventCode

    strHTML = strHTML & VbCrLf & "<br>Doelbestand: " & objEvent.SourceName    

    strHTML = strHTML & VbCrLf & "<br>Bericht: " & objEvent.Message

    strHTML = strHTML & VbCrLf & "<br>Tijd geschreven: " & objEvent.TimeWritten

    strHTML = strHTML & VbCrLf & "<br>Type: " & objEvent.Type

    strHTML = strHTML & VbCrLf & "<br><br>"

Next

 

wscript.echo strHTML

 

Open in New Window 

    
 

Grade Received: A

Grading Comments:

Open in new window

0
Comment
Question by:Dutchict
  • 9
  • 5
14 Comments
 
LVL 24

Expert Comment

by:purplepomegranite
ID: 21801576
Hi again JMSSupport,

The attached has been modified to suppress duplicate events (a duplicate being defined as the same event number from the same event source).
' Declare dictionary object for checking for duplicates

dim dicDupCheck

set dicDupCheck=CreateObject("Scripting.Dictionary")
 

' Set earliest time for events that we want

Set objSWbemDateTime = CreateObject("WbemScripting.SWbemDateTime")

objSWbemDateTime.SetVarDate FormatDateTime(DateAdd("D",-14,Now),2), true

' The -14 specifies up to 14 days ago... change as appropriate

 

strHTML = strHTML & VbCrLf & "<br><br><b>Logboeken FOUTEN:</b><br>"

 

strComputer="."

Set objWMIService = GetObject("winmgmts:" _

	& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

 

Set colLoggedEvents = objWMIService.ExecQuery _

	("Select * from Win32_NTLogEvent Where Logfile = 'System'" _

	& " and EventType = '1' and TimeWritten>='" & objSWbemDateTime.Value & "'")

 
 

For Each objEvent in colLoggedEvents

	if not dicDupCheck.Exists(objEvent.EventCode & objEvent.SourceName) then

		strHTML = strHTML & VbCrLf & "<br>Event Code: " & objEvent.EventCode

		strHTML = strHTML & VbCrLf & "<br>Doelbestand: " & objEvent.SourceName    

		strHTML = strHTML & VbCrLf & "<br>Bericht: " & objEvent.Message

		strHTML = strHTML & VbCrLf & "<br>Tijd geschreven: " & objEvent.TimeWritten

		strHTML = strHTML & VbCrLf & "<br>Type: " & objEvent.Type

		strHTML = strHTML & VbCrLf & "<br><br>"

		dicDupCheck.Add objEvent.EventCode & objEvent.SourceName, "1"

	end if

Next    

 

strHTML = strHTML & VbCrLf & "<br><br><b>Logboeken WAARSCHUWINGEN:</b><br>"

 

 

Set objWMIService = GetObject("winmgmts:" _

    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

 

Set colLoggedEvents = objWMIService.ExecQuery _

    ("Select * from Win32_NTLogEvent Where Logfile = 'System'" _

        & " and EventType = '2' and TimeWritten>='" & objSWbemDateTime.Value & "'")

dicDupCheck.RemoveAll ' Reset the dictionary

For Each objEvent in colLoggedEvents

	if not dicDupCheck.Exists(objEvent.EventCode & objEvent.SourceName) then 

		strHTML = strHTML & VbCrLf & "<br>Event Code: " & objEvent.EventCode

		strHTML = strHTML & VbCrLf & "<br>Doelbestand: " & objEvent.SourceName    

		strHTML = strHTML & VbCrLf & "<br>Bericht: " & objEvent.Message

		strHTML = strHTML & VbCrLf & "<br>Tijd geschreven: " & objEvent.TimeWritten

		strHTML = strHTML & VbCrLf & "<br>Type: " & objEvent.Type

		strHTML = strHTML & VbCrLf & "<br><br>"

		dicDupCheck.Add objEvent.EventCode & objEvent.SourceName, "1"

	end if

Next

 

wscript.echo strHTML

Open in new window

0
 
LVL 24

Expert Comment

by:purplepomegranite
ID: 21801580
Ah... I missed the count of duplicates... I'll modify to give a count...
0
 
LVL 24

Expert Comment

by:purplepomegranite
ID: 21801668
This seems to work.  I've modified the code so that it is more structured too.  It will help if you want further modifications!!
' Set earliest time for events that we want

Set objSWbemDateTime = CreateObject("WbemScripting.SWbemDateTime")

objSWbemDateTime.SetVarDate FormatDateTime(DateAdd("D",-1,Now),2), true

' The -14 specifies up to 14 days ago... change as appropriate

 

strHTML = strHTML & VbCrLf & "<br><br><b>Logboeken FOUTEN:</b><br>"

 

strComputer="."
 

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

Set colLoggedEvents = objWMIService.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'System' and EventType = '1' and TimeWritten>='" & objSWbemDateTime.Value & "'")

strHTML=strHTML & ReturnEventDetails(colLoggedEvents)

 

 

strHTML = strHTML & VbCrLf & "<br><br><b>Logboeken WAARSCHUWINGEN:</b><br>"

 

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

Set colLoggedEvents = objWMIService.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'System' and EventType = '2' and TimeWritten>='" & objSWbemDateTime.Value & "'")

strHTML=strHTML & ReturnEventDetails(colLoggedEvents)
 

wscript.echo strHTML
 

function ReturnEventDetails(colLoggedEvents)

	dim objEvent, dicDupCount, dicEventDetails, k

	dim strHTML, strEventHTML

	set dicDupCount=CreateObject("Scripting.Dictionary")

	set dicEventDetails=CreateObject("Scripting.Dictionary")

	

	For Each objEvent in colLoggedEvents

		if not dicDupCount.Exists(objEvent.EventCode & objEvent.SourceName) then

			strEventHTML = "<br>Event Code: " & objEvent.EventCode

			strEventHTML = strEventHTML & VbCrLf & "<br>Doelbestand: " & objEvent.SourceName    

			strEventHTML = strEventHTML & VbCrLf & "<br>Bericht: " & objEvent.Message

			strEventHTML = strEventHTML & VbCrLf & "<br>Tijd geschreven: " & objEvent.TimeWritten

			strEventHTML = strEventHTML & VbCrLf & "<br>Type: " & objEvent.Type

			dicDupCount.Add objEvent.EventCode & objEvent.SourceName, "1"

			dicEventDetails.Add objEvent.EventCode & objEvent.SourceName, strEventHTML

		else

			intCount=dicDupCount(objEvent.EventCode & objEvent.SourceName)+1

			dicDupCount(objEvent.EventCode & objEvent.SourceName)=intCount

		end if

	Next    
 

	' Now loop through dictionary and add to output

	k=dicDupCount.Keys

	for i=0 to dicDupCount.Count-1

		strHTML=strHTML & dicEventDetails(k(i))

		strHTML=strHTML & VbCrLf & "<br>Event count: " & dicDupCount(k(i)) & vbCrLf & "<br><br>"

	next

	strHTML = strHTML & VbCrLf & "<br><br><b>Logboeken WAARSCHUWINGEN:</b><br>"

	ReturnEventDetails=strHTML

	set dicDupCount=Nothing

	set dicEventDetails=Nothing

end function

Open in new window

0
 
LVL 24

Expert Comment

by:purplepomegranite
ID: 21801678
Sorry, was an extra line in the function that you don't want.  Didn't notice it due to the language, lol.  Attached.
' Set earliest time for events that we want

Set objSWbemDateTime = CreateObject("WbemScripting.SWbemDateTime")

objSWbemDateTime.SetVarDate FormatDateTime(DateAdd("D",-1,Now),2), true

' The -14 specifies up to 14 days ago... change as appropriate

 

strHTML = strHTML & VbCrLf & "<br><br><b>Logboeken FOUTEN:</b><br>"

 

strComputer="."
 

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

Set colLoggedEvents = objWMIService.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'System' and EventType = '1' and TimeWritten>='" & objSWbemDateTime.Value & "'")

strHTML=strHTML & ReturnEventDetails(colLoggedEvents)

 

strHTML = strHTML & VbCrLf & "<br><br><b>Logboeken WAARSCHUWINGEN:</b><br>"

 

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

Set colLoggedEvents = objWMIService.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'System' and EventType = '2' and TimeWritten>='" & objSWbemDateTime.Value & "'")

strHTML=strHTML & ReturnEventDetails(colLoggedEvents)
 

wscript.echo strHTML
 

function ReturnEventDetails(colLoggedEvents)

	dim objEvent, dicDupCount, dicEventDetails, k

	dim strHTML, strEventHTML

	set dicDupCount=CreateObject("Scripting.Dictionary")

	set dicEventDetails=CreateObject("Scripting.Dictionary")

	

	For Each objEvent in colLoggedEvents

		if not dicDupCount.Exists(objEvent.EventCode & objEvent.SourceName) then

			strEventHTML = "<br>Event Code: " & objEvent.EventCode

			strEventHTML = strEventHTML & VbCrLf & "<br>Doelbestand: " & objEvent.SourceName    

			strEventHTML = strEventHTML & VbCrLf & "<br>Bericht: " & objEvent.Message

			strEventHTML = strEventHTML & VbCrLf & "<br>Tijd geschreven: " & objEvent.TimeWritten

			strEventHTML = strEventHTML & VbCrLf & "<br>Type: " & objEvent.Type

			dicDupCount.Add objEvent.EventCode & objEvent.SourceName, "1"

			dicEventDetails.Add objEvent.EventCode & objEvent.SourceName, strEventHTML

		else

			intCount=dicDupCount(objEvent.EventCode & objEvent.SourceName)+1

			dicDupCount(objEvent.EventCode & objEvent.SourceName)=intCount

		end if

	Next    
 

	' Now loop through dictionary and add to output

	k=dicDupCount.Keys

	for i=0 to dicDupCount.Count-1

		strHTML=strHTML & dicEventDetails(k(i))

		strHTML=strHTML & VbCrLf & "<br>Event count: " & dicDupCount(k(i)) & vbCrLf & "<br><br>"

	next

	ReturnEventDetails=strHTML

	set dicDupCount=Nothing

	set dicEventDetails=Nothing

end function

Open in new window

0
 

Author Comment

by:Dutchict
ID: 21801751
Hi purplepomegranite, thanks again, only the last code gives a false output. Is it possible that the  script can't cope with the two wmi services?

Output latest script;
------------------------------------------------
Logboeken FOUTEN:


Logboeken WAARSCHUWINGEN:

Event Code: 3019
Doelbestand: MRxSmb
Bericht: De redirector kan het type van een verbinding niet vaststellen.
Tijd geschreven: 20080616142044.000000+120
Type: Waarschuwing
Event count: 4
-----------------------------------------

Output earlier script;
-----------------------------------------
Logboeken FOUTEN:

Event Code: 29
Doelbestand: W32Time
Bericht: De tijdsprovider NtpClient is geconfigureerd om de tijd uit een of meer tijdsbronnen te halen. Geen van deze bronnen zijn echter toegankelijk. Er worden geen nieuwe pogingen gedaan gedurende 15 minuten. De tijdservice heeft geen nauwkeurige tijdsbron.
Tijd geschreven: 20080605114636.000000+120
Type: Fout


Event Code: 6004
Doelbestand: EventLog
Bericht: Een besturingspakket van het IO-subsysteem is ongeldig. Raadpleeg het pakket voor meer gegevens.
Tijd geschreven: 20080612094721.000000+120
Type: Fout


Event Code: 4
Doelbestand: Kerberos
Bericht: The kerberos client received a KRB_AP_ERR_MODIFIED error from the server ROWALD$. This indicates that the password used to encrypt the kerberos service ticket is different than that on the target server. Commonly, this is due to identically named machine accounts in the target realm (DOMAIN.JMS), and the client realm. Please contact your system administrator.
Tijd geschreven: 20080612125835.000000+120
Type: Fout


Event Code: 10009
Doelbestand: DCOM
Bericht: DCOM kan met geen enkel van de protocollen die nu zijn geconfigureerd met de computer communiceren.
Tijd geschreven: 20080612145828.000000+120
Type: Fout


Event Code: 5789
Doelbestand: NETLOGON
Bericht: Poging tot bijwerken van DNS-hostnaam van het computerobject in Active Directory is mislukt. De bijgewerkte waarde is rowald.Domain.jms. De volgende fout is opgetreden: De endpointtoewijzer heeft geen endpoints meer beschikbaar. .
Tijd geschreven: 20080615060241.000000+120
Type: Fout


Event Code: 5788
Doelbestand: NETLOGON
Bericht: Poging tot bijwerken van HOST SPN's (Service Principal Names) van het computerobject in Active Directory is mislukt. De bijgewerkte waarden zijn HOST/rowald.Domain.jms en HOST/ROWALD. De volgende fout is opgetreden: De endpointtoewijzer heeft geen endpoints meer beschikbaar. .
Tijd geschreven: 20080615060241.000000+120
Type: Fout



Logboeken WAARSCHUWINGEN:

Event Code: 3019
Doelbestand: MRxSmb
Bericht: De redirector kan het type van een verbinding niet vaststellen.
Tijd geschreven: 20080610121431.000000+120
Type: Waarschuwing


Event Code: 24
Doelbestand: W32Time
Bericht: Tijdprovider/NtpClient: na 8 contactpogingen er is geen geldig antwoord ontvangen van domeincontroller jmsgs01.Domain.jms. Deze domeincontroller wordt niet meer als tijdsbron gebruikt en NtpClient probeert een nieuwe domeincontroller voor synchronisatie te vinden.
Tijd geschreven: 20080605114636.000000+120
Type: Waarschuwing


Event Code: 11197
Doelbestand: DnsApi
Bericht: Kan de A-bronrecords voor de netwerkadapter met de volgende instellingen niet bijwerken of verwijderen: Adapternaam: {45FF41CA-D548-408B-829F-038A1F73080B} Hostnaam: rowald Primair domeinachtervoegsel : Domain.jms DNS-serverlijst : 10.8.1.11, 10.8.1.1, 10.8.1.2, 62.45.45.45 Update verzonden naar server : 10.1.1.1 IP-adres(sen) : 10.8.1.144 De updateaanvraag is mislukt vanwege een systeemprobleem. Raadpleeg de onderstaande recordgegevens voor de specifieke foutcode.
Tijd geschreven: 20080612091846.000000+120
Type: Waarschuwing


Event Code: 36
Doelbestand: W32Time
Bericht: De systeemtijd is gedurende 49152 seconden niet door de tijdservice gesynchroniseerd omdat geen van de tijdproviders een bruikbaar tijdstempel heeft kunnen aanbieden. De systeemklok is niet gesynchroniseerd.
Tijd geschreven: 20080615221635.000000+120
Type: Waarschuwing
--------------------------------------

0
 
LVL 24

Expert Comment

by:purplepomegranite
ID: 21801781
Which latest script was it?  Sorry, I posted a couple prematurely, so I need to know which one is producing what.

The one below works fine on my system, returning a proper count for both WMI calls.  There is no problem with more than one call - but the fact they are both similar calls is why I procedurised the code.

The other point to note is that of course the event written property is only valid for the first event encountered by the routine.
' Set earliest time for events that we want

Set objSWbemDateTime = CreateObject("WbemScripting.SWbemDateTime")

objSWbemDateTime.SetVarDate FormatDateTime(DateAdd("D",-14,Now),2), true

' The -14 specifies up to 14 days ago... change as appropriate

 

strHTML = strHTML & VbCrLf & "<br><br><b>Logboeken FOUTEN:</b><br>"

 

strComputer="."
 

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

Set colLoggedEvents = objWMIService.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'System' and EventType = '1' and TimeWritten>='" & objSWbemDateTime.Value & "'")

strHTML=strHTML & ReturnEventDetails(colLoggedEvents)

 

strHTML = strHTML & VbCrLf & "<br><br><b>Logboeken WAARSCHUWINGEN:</b><br>"

 

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

Set colLoggedEvents = objWMIService.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'System' and EventType = '2' and TimeWritten>='" & objSWbemDateTime.Value & "'")

strHTML=strHTML & ReturnEventDetails(colLoggedEvents)
 

wscript.echo strHTML
 

function ReturnEventDetails(colLoggedEvents)

	dim objEvent, dicDupCount, dicEventDetails, k

	dim strHTML, strEventHTML

	set dicDupCount=CreateObject("Scripting.Dictionary")

	set dicEventDetails=CreateObject("Scripting.Dictionary")

	

	For Each objEvent in colLoggedEvents

		if not dicDupCount.Exists(objEvent.EventCode & objEvent.SourceName) then

			strEventHTML = vbCrLf & "<br>Event Code: " & objEvent.EventCode

			strEventHTML = strEventHTML & VbCrLf & "<br>Doelbestand: " & objEvent.SourceName    

			strEventHTML = strEventHTML & VbCrLf & "<br>Bericht: " & objEvent.Message

			strEventHTML = strEventHTML &  "<br>Tijd geschreven: " & objEvent.TimeWritten

			strEventHTML = strEventHTML & VbCrLf & "<br>Type: " & objEvent.Type

			dicDupCount.Add objEvent.EventCode & objEvent.SourceName, "1"

			dicEventDetails.Add objEvent.EventCode & objEvent.SourceName, strEventHTML

		else

			intCount=dicDupCount(objEvent.EventCode & objEvent.SourceName)+1

			dicDupCount(objEvent.EventCode & objEvent.SourceName)=intCount

		end if

	Next    
 

	' Now loop through dictionary and add to output

	k=dicDupCount.Keys

	for i=0 to dicDupCount.Count-1

		strHTML=strHTML & dicEventDetails(k(i))

		strHTML=strHTML & VbCrLf & "<br>Event count: " & dicDupCount(k(i)) & vbCrLf & "<br><br>" & vbCrLf & vbCrLf

	next

	ReturnEventDetails=strHTML

	set dicDupCount=Nothing

	set dicEventDetails=Nothing

end function

Open in new window

0
 
LVL 24

Expert Comment

by:purplepomegranite
ID: 21801810
And actually, just to completely overload this thread with code examples (sorry!!), the attached will save the output as an HTML file.  This makes it much easier to read, and also you don't lose a lot of the output, which you do if run in a command window.

It creates a file called output.htm in it's current directory.  Note it isn't complete HTML, but browsers should handle it ok anyway.
' Set earliest time for events that we want

Set objSWbemDateTime = CreateObject("WbemScripting.SWbemDateTime")

objSWbemDateTime.SetVarDate FormatDateTime(DateAdd("D",-14,Now),2), true

' The -14 specifies up to 14 days ago... change as appropriate

 

strHTML = strHTML & VbCrLf & "<br><br><b>Logboeken FOUTEN:</b><br>"

 

strComputer="."
 

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

Set colLoggedEvents = objWMIService.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'System' and EventType = '1' and TimeWritten>='" & objSWbemDateTime.Value & "'")

strHTML=strHTML & ReturnEventDetails(colLoggedEvents)

 

strHTML = strHTML & VbCrLf & "<br><br><b>Logboeken WAARSCHUWINGEN:</b><br>"

 

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

Set colLoggedEvents = objWMIService.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'System' and EventType = '2' and TimeWritten>='" & objSWbemDateTime.Value & "'")

strHTML=strHTML & ReturnEventDetails(colLoggedEvents)
 

dim objFSO

set objFSO=CreateObject("Scripting.FileSystemObject")

set objF=objFSO.CreateTextFile("output.htm",true)

objF.Write strHTML

objF.Close

set objF=Nothing

set objFSO=Nothing

wscript.echo strHTML
 

function ReturnEventDetails(colLoggedEvents)

	dim objEvent, dicDupCount, dicEventDetails, k

	dim strHTML, strEventHTML

	set dicDupCount=CreateObject("Scripting.Dictionary")

	set dicEventDetails=CreateObject("Scripting.Dictionary")

	

	For Each objEvent in colLoggedEvents

		if not dicDupCount.Exists(objEvent.EventCode & objEvent.SourceName) then

			strEventHTML = vbCrLf & "<br>Event Code: " & objEvent.EventCode

			strEventHTML = strEventHTML & VbCrLf & "<br>Doelbestand: " & objEvent.SourceName    

			strEventHTML = strEventHTML & VbCrLf & "<br>Bericht: " & objEvent.Message

			strEventHTML = strEventHTML &  "<br>Tijd geschreven: " & objEvent.TimeWritten

			strEventHTML = strEventHTML & VbCrLf & "<br>Type: " & objEvent.Type

			dicDupCount.Add objEvent.EventCode & objEvent.SourceName, "1"

			dicEventDetails.Add objEvent.EventCode & objEvent.SourceName, strEventHTML

		else

			intCount=dicDupCount(objEvent.EventCode & objEvent.SourceName)+1

			dicDupCount(objEvent.EventCode & objEvent.SourceName)=intCount

		end if

	Next    
 

	' Now loop through dictionary and add to output

	k=dicDupCount.Keys

	for i=0 to dicDupCount.Count-1

		strHTML=strHTML & dicEventDetails(k(i))

		strHTML=strHTML & VbCrLf & "<br>Event count: " & dicDupCount(k(i)) & vbCrLf & "<br><br>" & vbCrLf & vbCrLf

	next

	ReturnEventDetails=strHTML

	set dicDupCount=Nothing

	set dicEventDetails=Nothing

end function

Open in new window

0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 24

Expert Comment

by:purplepomegranite
ID: 21801829
It must be said, I should thank you for getting me involved in this code.  I need some script to monitor remote servers and send me an email with pertinent information - some of which is obviously the event log.  So this script is perfect as a basis for that - and I probably wouldn't have got around to it as quickly had you not asked the question!!
0
 

Author Comment

by:Dutchict
ID: 21801880
I am creating a script to view the most wanted data of a computer/server to check periodicly. The thing my script is getting frusted about is the wscript.echo strHTML. I will atach the full code here...
--------------
sorry for this long script, but it's what we want..lol

Please see you'r script active within this script, what can i do to replace the wscript.echo strhtml?
code.txt
0
 
LVL 24

Accepted Solution

by:
purplepomegranite earned 500 total points
ID: 21801952
The problem was actually the implementation of the function.  In VBScript, functions need to be at the end of the code, so yours was failing when my code was added into it.

I have amended your code by moving the function to the end.  I have also removed the redundant code (saving to disk and the wscript.echo line).  Tested and it works fine now.
code.txt
0
 

Author Comment

by:Dutchict
ID: 21802061
wow, that's the thing we needed! Thanks for your help (again!), next chalenge will be to check windows update and give a feedback to the html with the available updates..
0
 

Author Closing Comment

by:Dutchict
ID: 31467904
That's why you called a master here!
0
 
LVL 24

Expert Comment

by:purplepomegranite
ID: 21803180
Glad that part's done!

Incidentally, if you need further help developing this particular script, you can use the Ask a Related Question link at the bottom of this thread.  This will put a new question up, but means I receive an email to say that a related question has been asked.  This isn't to say that other experts can't or won't answer (they will see it as usual), it's just useful for follow-on questions where you have been helped already.
0
 

Author Comment

by:Dutchict
ID: 21810526
purplepomegranite, i have already opened a new question, i have found a script to check windows update for updates and drivers. Only to get this work within the script...  I also am bussy with a virusscan check on multiple antivirus software platforms, that will be the next question..lol

I hope you'll also like the script, when it is finished it will autocheck a server and place all results in a html file. That file can then be used to place on our customer lounge, so customers can view there reports and can see the actions we made in our logsystem. It will be a lot of code and take up to 3 minutes to run when finished but take a lot of work out of hands.

If you want i can place the final script (at the end of the run) here. There is a lot of  'face lifts" done to the output file, and there is a "wait till script ends" screen when running. Englisg translation will be available to.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Unlike scripting languages such as C# where a semi-colon is used to indicate the end of a command, Microsoft's VBScript language relies on line breaks to determine when a command begins and ends. As you can imagine, this quickly results in messy cod…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now