salut à tous !
Voila un bon moment que je n avais pas poster de message !
voila mon probleme : j'ai une liste d'ordinateur WINDOWS dans un fichier excel,
le but de mon script est de pinger le poste voir si il est actif, puis de faire une requete sur ces logs applications pour retrouver des evenements !
voila mon code:
Do While objExcel.Cells(intRow,1).Value <> ""
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_PingStatus where address = '" & objExcel.Cells(intRow,1) & "'")
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
WScript.Echo("machine " & objExcel.Cells(intRow,1) & " is not reachable")
objWorksheet.Cells(intRow,2) = "Host Unreachable"
intRow=intRow+1
Else
WScript.Echo("machine " & objExcel.Cells(intRow,1) & " responded: pong!")
objExcel.Cells(intRow,2) = "Host responded"
i=0
y=0
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & objExcel.Cells(intRow,1).Value & "\root\cimv2")
If objWMIService Is Nothing Then
WScript.Echo "Unable to bind to WMI on " & objExcel.Cells(intRow,1).Value
Else
Set colLoggedEvents = objWMIService.ExecQuery ("Select * from Win32_NTLogEvent Where Logfile='Application'")
If Err.Number <> 0 Then
WScript.Echo "ROW=" & intRow & ",Description : " & Err.Number
objExcel.Cells(intRow,5) = "" & Err.Number & ""
If (objEvent.EventCode = "15") AND (StrComp("AutoEnrollment",objEvent.SourceName) = 0 ) Then
i=i+1
ElseIf (objEvent.EventCode = "1054") AND (StrComp("Userenv",objEvent.SourceName) = 0 ) Then
y=y+1
End If
Else
REM i = 0
REM y = 0
Wscript.echo "Hinhiiiiiiin"
For Each objEvent in colLoggedEvents
If (objEvent.EventCode = "15") AND (StrComp("AutoEnrollment",objEvent.SourceName) = 0 ) Then
i=i+1
ElseIf (objEvent.EventCode = "1054") AND (StrComp("Userenv",objEvent.SourceName) = 0 ) Then
y=y+1
End If
Next
End If
'oFileResult.Writeline("" & objExcel.Cells(intRow,1).Value & ";" & i & ";" & y & "")
objExcel.Cells(intRow,3) = "" & i & ""
objExcel.Cells(intRow,4) = "" & y & ""
intRow=intRow+1
End If
End If
Next
Wscript.Sleep 15000
Loop
Wscript.echo "Fin du fichier Excel"
Et j'ai un gros probleme c'est que à partir d'un petit nombre d ordinateur passés et bien ca foire totalement ... je m explique :
wsh ou wmi je sais pas trop me renvoie des erreurs de type "-2147217407" ou 424 .... comme si il y avait un probleme de timeout ou je ne sais quoi ... bref la galere ! pour des postes de manières individuels le script fonctionne tres bien .. sauf que j'ai 2000 machines à checker xD
Merci d'avance !
hin hin!