<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to get tasks within a specific time interval? in VMware PowerCLI Discussions</title>
    <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/How-to-get-tasks-within-a-specific-time-interval/m-p/2919328#M107448</link>
    <description>&lt;P&gt;I have a script which uses Get-TaskPlus script to fetch tasks from vCenter within a specific time interval but it seems that the results are not accurate.&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;param(&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;[datetime]$start,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;[datetime]$finish,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;[Int32]$MaxSamples=250&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;. ".\Get-TaskPlus.ps1"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;$Template = "WebTinyCentOS65x86"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;$TaskName = "CloneVM_Task"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;$TemplateName = Get-Template $Template&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;$tasks = Get-TaskPlus -Entity $TemplateName -MaxSamples $MaxSamples -Start (Get-Date -Day $start.Day -Month $start.Month -Year $start.Year -Hour $start.Hour -Minute $start.Minute -Second $start.Second) -Finish (Get-Date -Day $finish.Day -Month $finish.Month -Year $finish.Year -Hour $finish.Hour -Minute $finish.Minute -Second $finish.Second) | where name -eq $TaskName&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;$TimeList = @()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;$Time = $tasks.TimeDifference&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;$TimeList = $TimeList + $Time&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;$TotalTime = [System.TimeSpan]::new( 0 )&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;$TimeList | ForEach-Object{ $TotalTime += $_ }&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;$tasks | Select Name, TaskCreated, TaskStarted, TaskEnded, Entity, VIServer, TimeDifference | ConvertTo-Json&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;Write-Output "Total Time: $($TotalTime)"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;Write-Output "Tasks Count: $($tasks.Count)"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;I use this command to run my script: &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;./getTasks.ps1 -Start "2022-07-19 05:30:22 AM" -Finish "2022-07-19 05:37:22 AM"&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;This script works fine but somehow picks first task from&amp;nbsp;&lt;STRONG&gt;2022-07-19 05:30:22 AM&lt;/STRONG&gt; and last task from &lt;STRONG&gt;2022-07-19 05:36:39 AM&lt;/STRONG&gt;. When I check the tasks in vCenter, I see that some tasks are not there in the result which occurred between &lt;STRONG&gt;[2022-07-19 05:30:22 AM -- 2022-07-19 05:30:22 AM]&lt;/STRONG&gt; and between &lt;STRONG&gt;[2022-07-19 05:36:39 AM -- 2022-07-19 05:37:22 AM]&lt;/STRONG&gt;.&lt;BR /&gt;And also the number of tasks should be 105 but my script shows 220 tasks between this interval.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Jul 2022 13:34:49 GMT</pubDate>
    <dc:creator>arpit0903</dc:creator>
    <dc:date>2022-07-19T13:34:49Z</dc:date>
    <item>
      <title>How to get tasks within a specific time interval?</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/How-to-get-tasks-within-a-specific-time-interval/m-p/2919328#M107448</link>
      <description>&lt;P&gt;I have a script which uses Get-TaskPlus script to fetch tasks from vCenter within a specific time interval but it seems that the results are not accurate.&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;param(&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;[datetime]$start,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;[datetime]$finish,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;[Int32]$MaxSamples=250&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;. ".\Get-TaskPlus.ps1"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;$Template = "WebTinyCentOS65x86"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;$TaskName = "CloneVM_Task"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;$TemplateName = Get-Template $Template&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;$tasks = Get-TaskPlus -Entity $TemplateName -MaxSamples $MaxSamples -Start (Get-Date -Day $start.Day -Month $start.Month -Year $start.Year -Hour $start.Hour -Minute $start.Minute -Second $start.Second) -Finish (Get-Date -Day $finish.Day -Month $finish.Month -Year $finish.Year -Hour $finish.Hour -Minute $finish.Minute -Second $finish.Second) | where name -eq $TaskName&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;$TimeList = @()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;$Time = $tasks.TimeDifference&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;$TimeList = $TimeList + $Time&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;$TotalTime = [System.TimeSpan]::new( 0 )&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;$TimeList | ForEach-Object{ $TotalTime += $_ }&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;$tasks | Select Name, TaskCreated, TaskStarted, TaskEnded, Entity, VIServer, TimeDifference | ConvertTo-Json&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;Write-Output "Total Time: $($TotalTime)"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;Write-Output "Tasks Count: $($tasks.Count)"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;I use this command to run my script: &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;./getTasks.ps1 -Start "2022-07-19 05:30:22 AM" -Finish "2022-07-19 05:37:22 AM"&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;This script works fine but somehow picks first task from&amp;nbsp;&lt;STRONG&gt;2022-07-19 05:30:22 AM&lt;/STRONG&gt; and last task from &lt;STRONG&gt;2022-07-19 05:36:39 AM&lt;/STRONG&gt;. When I check the tasks in vCenter, I see that some tasks are not there in the result which occurred between &lt;STRONG&gt;[2022-07-19 05:30:22 AM -- 2022-07-19 05:30:22 AM]&lt;/STRONG&gt; and between &lt;STRONG&gt;[2022-07-19 05:36:39 AM -- 2022-07-19 05:37:22 AM]&lt;/STRONG&gt;.&lt;BR /&gt;And also the number of tasks should be 105 but my script shows 220 tasks between this interval.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 13:34:49 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/How-to-get-tasks-within-a-specific-time-interval/m-p/2919328#M107448</guid>
      <dc:creator>arpit0903</dc:creator>
      <dc:date>2022-07-19T13:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to get tasks within a specific time interval?</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/How-to-get-tasks-within-a-specific-time-interval/m-p/2919336#M107449</link>
      <description>&lt;P&gt;One aspect that might explain the differences is the TimeType property in the filter.&lt;BR /&gt;If your Get-TaskPlus is referring to my Get-TaskPlus function then in there I used the&amp;nbsp;&lt;SPAN class="crayon-sy"&gt;[&lt;/SPAN&gt;&lt;SPAN class="crayon-i"&gt;vmware&lt;/SPAN&gt;&lt;SPAN class="crayon-sy"&gt;.&lt;/SPAN&gt;&lt;SPAN class="crayon-i"&gt;vim&lt;/SPAN&gt;&lt;SPAN class="crayon-sy"&gt;.&lt;/SPAN&gt;&lt;SPAN class="crayon-i"&gt;taskfilterspectimeoption&lt;/SPAN&gt;&lt;SPAN class="crayon-sy"&gt;]&lt;/SPAN&gt;&lt;SPAN class="crayon-sy"&gt;:&lt;/SPAN&gt;&lt;SPAN class="crayon-sy"&gt;:&lt;/SPAN&gt;&lt;SPAN class="crayon-i"&gt;startedTime&lt;/SPAN&gt;&lt;BR /&gt;The other options are queued and completed.&lt;BR /&gt;It is possible that the Web CLient uses another type then startedTime.&lt;BR /&gt;&lt;BR /&gt;Do all the StartTime values in the returned Tasks fall within the specified interval?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 14:19:58 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/How-to-get-tasks-within-a-specific-time-interval/m-p/2919336#M107449</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2022-07-19T14:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to get tasks within a specific time interval?</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/How-to-get-tasks-within-a-specific-time-interval/m-p/2919374#M107452</link>
      <description>&lt;P&gt;Yes, I am using your Get-TaskPlus function and all the StartTime values in the returned Tasks also fall within the specified interval, but some of the tasks are missing which also fall within the specified time interval.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 16:40:18 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/How-to-get-tasks-within-a-specific-time-interval/m-p/2919374#M107452</guid>
      <dc:creator>arpit0903</dc:creator>
      <dc:date>2022-07-19T16:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to get tasks within a specific time interval?</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/How-to-get-tasks-within-a-specific-time-interval/m-p/2919376#M107454</link>
      <description>&lt;P&gt;Are you sure that the missing tasks actually started in that interval?&lt;BR /&gt;I just checked in my lab, and for me, it seems to be working ok.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 16:42:52 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/How-to-get-tasks-within-a-specific-time-interval/m-p/2919376#M107454</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2022-07-19T16:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to get tasks within a specific time interval?</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/How-to-get-tasks-within-a-specific-time-interval/m-p/2919466#M107468</link>
      <description>&lt;P&gt;Yes I am sure that missing tasks also started in the same interval.&lt;/P&gt;&lt;P&gt;Even if I am running this command: &lt;STRONG&gt;$tasks = Get-TaskPlus -Entity $TemplateName -Start "2022-07-19 05:34:16 AM" -Finish "2022-07-19 05:37:16 AM", &lt;/STRONG&gt;the function is not returning even a single task and there are around 100 tasks between this interval &lt;STRONG&gt;[&lt;/STRONG&gt;&lt;STRONG&gt;2022-07-19 05:34:16 AM&lt;/STRONG&gt; -- &lt;STRONG&gt;2022-07-19 05:37:16 AM]&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 06:02:12 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/How-to-get-tasks-within-a-specific-time-interval/m-p/2919466#M107468</guid>
      <dc:creator>arpit0903</dc:creator>
      <dc:date>2022-07-20T06:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to get tasks within a specific time interval?</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/How-to-get-tasks-within-a-specific-time-interval/m-p/2919657#M107477</link>
      <description>&lt;P&gt;Sorry, I can't reproduce what you are seeing.&lt;BR /&gt;&lt;BR /&gt;Perhaps some more concrete info like a screenshot of the tasks in the Web client and a run of your code would help.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 07:14:07 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/How-to-get-tasks-within-a-specific-time-interval/m-p/2919657#M107477</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2022-07-21T07:14:07Z</dc:date>
    </item>
  </channel>
</rss>

