I was looking at getting error event logs from the previous day, when looking at the different post on the forums I come across different day/time PowerShell formats that range from a specific date. I was looking at this PowerShell format for a date
Example 11: Get all errors in an event log that occurred during a specific time frame
PowerShellCopy
PS C:\> $May31 = Get-Date 5/31/08
PS C:\> $July1 = Get-Date 7/01/08
PS C:\> Get-EventLog -Log "Windows PowerShell" -EntryType Error -After $May31 -before $July1
I was wondering what would be the correct way to have this PowerShell search for errors from the previous day, so if its run on Tuesday it will gather all Mondays, Friday will gather all Thursdays. This is how I started doing it with no success.
PowerShellCopy
PS C:Get-EventLog -LogName System -EntryType Error, Warning; starttime=[datetime]::today
PS C:Get-EventLog -LogName Application -EntryType Error, Warning; startime=[datetime]::today
PS C:Get-EventLog -LogName Security -EntryType Error, Warning; starttime=[datetime]::today