Carrying on my prolific Monday..

Many that know me, know im not a fan of the Windows Task Scheduler.. It seems far to much work and nowhere near as clean and pretty as the SQL Server Agent.

Anyway.. today i had to dig through the history of a single task to find out how long it was taking to run. If you look at the history of a task it shows a lot of tasks per run, including Task started, task lunched action, task successfully completed, task successfully finished.

Reading through the GUI is not the cleanest easist of ways so I thought i would look in Powershell and see what we can do.

turns out that the Task Schedule is in Get-WinEvent under Microsoft-Windows-TaskScheduler/Operational.

Im sure this can be greatly improved but it got me what i needed.

Get-WinEvent Microsoft-Windows-TaskScheduler/Operational -maxEvents 10000 | where { $_.ActivityId -eq 'e4ce209e-c079-4398-91e8-2db33b72e6bf'} | where {$_.Id -eq 102 -or $_.Id -eq 100} 

this is based on my Tasks ActivityID being ‘e4ce209e-c079-4398-91e8-2db33b72e6bf’ which i got from the GUI history:


Pulls out something like this, got me what i needed.. not clean but again it does the job, which what i love about PowerShell.. We aren’t all Jeffrey Snover and thankful we don’t need to be!