I am trying to use PowerShell to get the results from the TaskScheduler events since yesterday. This is my code:
Get-WinEvent -LogName Microsoft-Windows-TaskScheduler/Operational -MaxEvents 5 |
Where-Object ($_.TimeCreated -gt [DateTime]::Today.AddDays(-1))
Format-List *
Notes:
The
-MaxEvents 5
is to limit output while I am developing.When I remove the
Where-object
the cmdlet returns a full list. This is expected since no filtering is applied. So the error must be in the way the filtering is being done.