WMI Connections and Server name
Hi, I am using For Each container loop to read set of data in to variables and populating my WMI reader Task. WMI reader task uses WMI connection. I am assigning the Server Name for the WMI connnection during the run time of for each loop. Expression for WMI Connection is like that Expression ServerName @[User::WMIConnection] I have verified the my @[User::WMIConnection] variable has the proper server name like \\servername but it is not poulating the serverName filed of WMI connection. I also tried to assign the ServerName property using Script Task but DTS.Connection("conn") does not have the ServerName property. Please Guide
November 8th, 2006 11:05pm

It looks like WMI reader task has lot of problems. Here is what I have found It does not allow to dynamically change the ServerName using Expression.(I used a work around in Script task to change the ConnectionString property during runtime) WQL language for WMI does not filter data perfectly using date criteria. See post http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=895879&SiteID=1 If there is no data for the given query, it fails with the following error message Operation is not valid due to the current state of the object. Your comments for the above points will be greatly appreciated.
Free Windows Admin Tool Kit Click here and download it now
November 9th, 2006 6:04pm

Hi, Does anyone knows the SSIS is using WQL Or Extended WQL (http://msdn2.microsoft.com/en-us/library/aa508695.aspx) in WMI data reader task. As an extended WQL will allow the use of Count and DATEDIFF function. If I use the count/datediff function I can solve my problem as mentioned in point 2 & 3 in the above post.
November 9th, 2006 10:38pm

Re: 2 By Using GMT datetime format, It has solve the porblem SELECT ComputerName, Logfile, RecordNumber, Category, CategoryString, EventCode, EventIdentifier, EventType, Message, SourceName, TimeGenerated, TimeWritten, Type, User FROM Win32_NTLogEvent Where LogFile = 'Application' and ( TimeWritten >= '20061112000000.000000-300' and TimeWritten < '20061113000000.000000-300' ) Re: 3 I write this small script(Script Task) to find out if there is any log entry exists before actually running the WMI data reader task. Below is the script for reference Imports System.Diagnostics Public Sub Main() Dim entry As EventLogEntry Dim entryCount As Int32 Dim entryIndex As Int32 Dim entryDate As DateTime Dim logDate As DateTime Dim ShouldContinue As Boolean Dim DaysDiff As Int64 Dim Count As Int16 Dim evtLog As EventLog = New EventLog() evtLog.MachineName = Dts.Variables("Server").Value.ToString evtLog.Log = Dts.Variables("LogType").Value.ToString logDate = CType(Dts.Variables("LogDate").Value, DateTime) Count = 0 Try 'Get the Count of entries and loop from backward entryCount = evtLog.Entries.Count - 1 For entryIndex = entryCount To 0 Step -1 'Get the Entry entry = evtLog.Entries(entryIndex) If Not (entry Is Nothing) Then 'Get The Days Difference between Requested Date and LogDate entryDate = entry.TimeWritten.Date() DaysDiff = DateDiff(DateInterval.Day, logDate, entryDate) Select Case DaysDiff Case 0 Count = CType(Count + 1, Int16) Exit For Case Is < 0 Exit For End Select End If Next Catch Ex As Exception Count = 0 End Try Dts.Variables("EntryCount").Value = CType(Count, Int16) ' ' EntryCount > 0 means log entry exists. Use expression to test this condition before running WMI reader task Dts.TaskResult = Dts.Results.Success End Sub
Free Windows Admin Tool Kit Click here and download it now
November 13th, 2006 9:43pm

Hi Shafiqm, I am also working with the WIM Data Reader object and also noticed that its not possible to use"expressions" to set the server name dynamically. Can you point out how this might by done programatically? Thanks,PK
November 27th, 2006 8:22am

Use Script Task, to set the ConnectionString property of the WMI connection. Suppose your WMI connection name is "WMI" and you have the servername in a variable called WMIConnection. Then you can set the connection string property as follows. But this will allow you to expose your userid/password hardcoded or you can use UseNatAuth=True for Trusted connection Dts.Connections("WMI").ConnectionString = "ServerName=" & Dts.Variables("WMIConnection").Value.ToString & ";NameSpace=\root\cimv2;UseNetAuth=False;UserName=domain\userid;Password=password;" Or Dts.Connections("WMI").ConnectionString = "ServerName=" & Dts.Variables("WMIConnection").Value.ToString & ";NameSpace=\root\cimv2;UseNetAuth=True;" Note: WMIConnection variable should hold server name like \\MyServer But WMI data reader task has problems when there is no matching data found matching to your criteria. It will simply fail. Also you can't use count function in WMI but the extended WSQL allows you to use the count function. Thanks Shafiq
Free Windows Admin Tool Kit Click here and download it now
November 28th, 2006 7:01pm

Thanks Shafiq!
December 3rd, 2006 1:36am

Hi shafiqm Have you got any examples of this code or a zip file in vb.net or wmi that you can send to me becasue i am doing a similair program to yourself and i am first time programmer please my email is f_4yub@hotmail.co.uk thank you very much
Free Windows Admin Tool Kit Click here and download it now
December 31st, 2010 5:28am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics