For those looking for a one-liner alternative, you can use the AddDays method as shown in the following command to retrieve events for the last 24 hours.- Get-EventLog -LogName system -EntryType Error, Warning -After (Get-Date).AddDays(-1)
复制代码 To retrieve events from yesterday starting at midnight, use the Date method prior to AddDays.- Get-EventLog -LogName system -EntryType Error, Warning -After (Get-Date).Date.AddDays(-1)
复制代码
|