Using WMI Data Reader and WMI Event Watcher Tasks in SSIS

7.      For  WQLQuerySource   you need to enter  the below   WMI Query. This query will keep polling the “D:Package” directory for the availability of a new file being written to trigger the event.   

WMI Query

SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA “CIM_DirectoryContainsFile” AND TargetInstance.GroupComponent = “Win32_Directory.Name=”D:\\Package””

8.      For  ActionAtEvent   specify the action to be taken when the event occurs. In this example choose “Log the event and fire the SSIS event” from the drop down list.

9.      For  AfterEvent   specify the action to be taken once the event has occurred. In this example  choose “Return with success” from the drop down list.

10.  For  ActionAtTimeout   specify the action to be taken when the timeout occurs. In this example  choose “Log the timeout and fire the SSIS event” from the drop down list.

11.  For  AfterTimeout   specify the action to be taken after the timeout. In this example choose “Return with failure” from the drop down list.

12.  For  NumberOfEvents   specify the number of events that the task watches. In this example set the value to 1.

13.  Next you need to specify the Timeout value in seconds. In this example specify the value as 0 which means the task will wait until the event occurs.

14.  This completes the configuration of the WMI Event Watcher Task as shown below:

15.  Finally, Click OK to save the WMI Event Watch Task.

Configuring the WMI Data Reader Task

1.      Drag and drop the WMI Data Reader Task from the toolbox to the Control Flow window of WMITasks.dtsx Package.

2.      Double click the WMI Data Reader Task to open up the WMI Data Reader Task Editor and navigate to the WMI Options tab as shown in the snippet below.

3.      In the WMI Data Reader Task Editor, you will need to configure a WMI Connection by clicking <New WMI Connection…> from the drop down list. This will open the WMI Connection Manager Editor as shown in the below snippet. In the WMI Connection Manager Editor set the connection name as “WMI Data Reader Connection Manager” and select the check box to use Windows Authentication. Leave the other values unchanged and click OK to save the WMI Connection Manager.

 

4.      For  WQLQuerySourceType there are three different options  – Direct Input, File Connection and Variable. In this example  choose Direct Input.

5.      For  WQLQuerySource enter the below WMI Query. This query will list all the windows services which are running on a local machine.  

 

WMI Query

 

SELECT DisplayName, StartMode, State FROM Win32_Service

 

6.      For  OutputType   specify the output type as Data Table.

7.      For  OverwriteDestination   specify whether the data in the destination file or variable is kept, overwritten or appended. In this example  choose “Overwrite Destination”   from the drop down list.

8.      For  DestinationType   specify the destination type. In this example  select “File connection”   from the drop down list.

9.      For  Destination   specify the file connection or variable that is the destination of the data. This can be done by clicking <New Connection…> from the drop down list. It will open up File Connection Manager Editor as shown in the below snippet. In the File Connection Manager Editor choose Usage Type as “Create file” and specify the path for the output file and click OK to save the File Connection Manager.

10.  This completes the configuration of the WMI Data Reader Task and it will look similar to the snippet   shown below.

11.   Finally, Click OK to save the WMI Data Reader Task.

Continues…

Leave a comment

Your email address will not be published.