
<sampler name="Scheduled Tasks">
	<sampleInterval>
		<data>600</data>
	</sampleInterval>
	<var-hideColumns>
		<data>
			<column>
				<data>Power Management</data>
			</column>
			<column>
				<data>Delete Task If Not Rescheduled</data>
			</column>
			<column>
				<data>Repeat: Until: Time</data>
			</column>
			<column>
				<data>Repeat: Until: Duration</data>
			</column>
			<column>
				<data>Repeat: Stop If Still Running</data>
			</column>
			<column>
				<data>Repeat: Every</data>
			</column>
			<column>
				<data>Schedule</data>
			</column>
		</data>
	</var-hideColumns>
	<plugin>
		<toolkit>
			<samplerScript>
				<data>c:\Windows\System32\cscript.exe /nologo taskscript.vbs</data>
			</samplerScript>
			<script>
				<contents>
					<data>function extractFieldValue(line)
 s = split(line,&quot;:&quot;,2)
 str = Replace(s(1), &quot;,&quot;, &quot;;&quot;)
 extractFieldValue = trim(str)
 end function
   
 function extractFieldName(line)
 s = split(line,&quot;:&quot;,2)
 str = Replace(s(0), &quot;,&quot;, &quot;;&quot;)
 extractFieldName = trim(str)
 end function
   
 jobfilter = &quot;Task&quot;

 &apos;***** Run the command
   
 Set WshShell = WScript.CreateObject(&quot;WScript.Shell&quot;)
 Set oExec = WshShell.Exec(&quot;c:\windows\system32\schtasks.exe /query /fo list /v&quot;)
   
 newline = &quot;&quot;
 header = &quot;&quot;
 first = 1
   
 &apos;***** Process the output
 Do While oExec.StdOut.AtEndOfStream &lt;&gt; True
   
 sline=oExec.StdOut.ReadLine
   
   
 if sline = &quot;&quot; then
 &apos;****This is the line break
 if newline &lt;&gt; &quot;&quot; then
   
 if first = 1 and header &lt;&gt; &quot;&quot; then
 &apos;**** Print column headers
   
 header = left(header,len(header)-1)
 wscript.echo header
 header = &quot;&quot;
 first = 0
 end if
   
 &apos;***Remove last comma
 newline = left(newline,len(newline)-1)
   
 if(InStr(newline,jobfilter) &gt; 0) then
 wscript.echo newline
 end if
   
 newline = &quot;&quot;
   
 end if
   
 elseif (InStr(1, sline,&quot;Folder:&quot;) &gt; 0) or (InStr(1, sline,&quot;INFO:&quot;) &gt; 0) then
   
 &apos;wscript.echo &quot;folder&quot;
   
 elseif (InStr(1, sline, &quot;: &quot;) &gt; 0) then
   
 newline = newline &amp; extractFieldValue(sline) &amp; &quot;,&quot;
   
 if first = 1 then
 header = header &amp; extractFieldName(sline) &amp; &quot;,&quot;
 &apos;wscript.echo header
 end if
   
 &apos;wscript.echo extractFieldValue(sline)
   
 end if
 Loop</data>
				</contents>
				<filename>
					<data>taskscript.vbs</data>
				</filename>
			</script>
		</toolkit>
	</plugin>
	<dataviews>
		<dataview name="Scheduled Tasks">
			<firstColumn>
				<create>
					<columnName>Long Task Name</columnName>
					<combineColumns>
						<column>HostName</column>
						<literal> </literal>
						<column>TaskName</column>
					</combineColumns>
				</create>
			</firstColumn>
		</dataview>
	</dataviews>
</sampler>