I cannot get this to work. I've looked at the objects and
am cornfused. It works through the registry queries but does not give me what I need from the application event log.
On Error Resume Next
Dim strComputer, strPingResults
DIM fso, IPAKFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set IPAKFile = fso.CreateTextFile("verify_RA_Svr_Snp_PING.txt", True)
Const HKEY_LOCAL_MACHINE = &H80000002
Set InputFile = fspenTextFile("MachineList.Txt")
Do While Not (InputFile.atEndOfStream)
strComputer = InputFile.ReadLine
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshExec = WshShell.Exec("ping -n 3 -w 2000 " & strComputer) 'send 3 echo requests, waiting 2secs each
strPingResults = LCase(WshExec.StdOut.ReadAll)
If InStr(strPingResults, "reply from") Then
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
IPAKFile.WriteLine strComputer
strKeyPath = "SOFTWARE\Altiris\Express\Recovery Solution Agent"
strValueName = "Agent Name"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
If isnull(strValue) then
IPAKFile.WriteLine("Altiris Recovery Solution Agent is not installed")
else
IPAKFile.WriteLine strValue & (" is installed.")
end if
strKeyPath = "SOFTWARE\Altiris\Express\Recovery Solution Agent"
strValueName = "ServerAddress"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
If IsNull(strValue) then
IPAKFile.WriteLine("There is NO Recovery Server Listed")
Else
IPAKFile.WriteLine("Recovery Server: ") & strValue
End If
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'Application' and " & "EventCode = '31' and " & "Message = 'Snapshot completed successfully'")
IPAKFile.WriteLine("Successful Snapshots: ") & colLoggedEvents.Count
Else
IPAKFile.WriteLine("Computer :") & strComputer & (" cannot be reached.")
End If
IPAKFile.WriteLine(".................................................")
loop
Wscript.Echo "Done"
am cornfused. It works through the registry queries but does not give me what I need from the application event log.
On Error Resume Next
Dim strComputer, strPingResults
DIM fso, IPAKFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set IPAKFile = fso.CreateTextFile("verify_RA_Svr_Snp_PING.txt", True)
Const HKEY_LOCAL_MACHINE = &H80000002
Set InputFile = fspenTextFile("MachineList.Txt")
Do While Not (InputFile.atEndOfStream)
strComputer = InputFile.ReadLine
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshExec = WshShell.Exec("ping -n 3 -w 2000 " & strComputer) 'send 3 echo requests, waiting 2secs each
strPingResults = LCase(WshExec.StdOut.ReadAll)
If InStr(strPingResults, "reply from") Then
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
IPAKFile.WriteLine strComputer
strKeyPath = "SOFTWARE\Altiris\Express\Recovery Solution Agent"
strValueName = "Agent Name"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
If isnull(strValue) then
IPAKFile.WriteLine("Altiris Recovery Solution Agent is not installed")
else
IPAKFile.WriteLine strValue & (" is installed.")
end if
strKeyPath = "SOFTWARE\Altiris\Express\Recovery Solution Agent"
strValueName = "ServerAddress"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
If IsNull(strValue) then
IPAKFile.WriteLine("There is NO Recovery Server Listed")
Else
IPAKFile.WriteLine("Recovery Server: ") & strValue
End If
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'Application' and " & "EventCode = '31' and " & "Message = 'Snapshot completed successfully'")
IPAKFile.WriteLine("Successful Snapshots: ") & colLoggedEvents.Count
Else
IPAKFile.WriteLine("Computer :") & strComputer & (" cannot be reached.")
End If
IPAKFile.WriteLine(".................................................")
loop
Wscript.Echo "Done"