I'm using SQL Server 2005, SP2, and SSIS as the package designer. I have (thanks to a script I found on the internet) created a script package that looks at the Event Viewer logs on a designated machine. It executes fine, but I need to store the results in a table somewhere. In fact, I want to modify this script to look at several servers at the same time, and report the results back to one table in the database. I'm VERY new to SSIS and am finding it particularly finiky and frustrating! (Where did DTS go...?).
Code:
Imports System
Imports System.Data
Imports System.Diagnostics
Imports System.Threading
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
' The execution engine calls this method when the task executes.
' To access the object model, use the Dts object. Connections, variables, events,
' and logging features are available as static members of the Dts class.
' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
'
' To open Code and Text Editor Help, press F1.
' To open Object Browser, press Ctrl+Alt+J.
Public Shared Function GetEventLogs(ByVal machineName As String) As EventLog()
Dim returnValue As EventLog()
returnValue = EventLog.GetEventLogs(machineName)
End Function
Public Sub Main()
Dim remoteEventLogs() As EventLog
remoteEventLogs = EventLog.GetEventLogs("myserver")
Console.WriteLine(("Number of logs on computer: " & remoteEventLogs.Length))
Dim log As EventLog
For Each log In remoteEventLogs
Console.WriteLine(("Log: " & log.Log))
Next log
Dts.TaskResult = Dts.Results.Success
End Sub
End Class