Aug 07 2024 08:00 PM
Does anyone know if it is possible to define a time range when using Get-WinEvent in PowerShell? It appears to work when specifying StartTime, but encounters issues when setting both StartTime and EndTime.
Working example:
```powershell
Get-WinEvent -FilterHashTable @{'LogName' = 'Application'; 'StartTime' = Get-Date "November 26, 2023 14:00:00"; }
```
Encountering issues:
```powershell
Get-WinEvent -FilterHashTable @{'LogName' = 'Application'; 'StartTime' = Get-Date "November 26, 2023 14:00:00"; 'EndTime' = Get-Date "November 26, 2023 14:01:00"}
Get-WinEvent : No events were found that match the specified selection criteria.
At line:1 char:1
+ Get-WinEvent -FilterHashTable @{LogName='Application';StartTime='01/0 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [Get-WinEvent], Exception
+ FullyQualifiedErrorId : NoMatchingEventsFound,Microsoft.PowerShell.Commands.GetWinEventCommand
```
Aug 16 2024 11:09 PM
Aug 22 2024 01:35 AM
Aug 27 2024 12:24 AM
Aug 29 2024 02:52 AM
If you still encounter issues, check if the Windows Event Log contains events in that specific time range and if the time zone settings are correct, as this may affect the results.