Search code examples
powershellget-winevent

Get start end time of specific task in event log


Hey i am trying to get the start and finish time of a scheduled task in the event log.

I followed the steps here Task Scheduler - get history information into script variables But i can not figure out how to modify it to get just the info from one task.

I have tried to modify the hashtable filter

`$EventFilter = @{
    LogName = 'Microsoft-Windows-TaskScheduler/Operational'
    Id = 100
    TaskName = '\Repository'
    StartTime = [datetime]::Now.AddDays(-1)
}`

But that returns the error

Get-WinEvent : No events were found that match the specified selection criteria.

I have tried to find info on this but i can't seem to find anything that points to getting just one task.

Any help would be welcome.


Solution

  • Found the answer Here It seems instead of searching for the data name xml you just search data with any of the fields that can be there.

    Hope that makes sense.