Get windows events for a day
16,125
This PowerShell command will return the event logs for the previous 24 hours:
Get-EventLog Application -After (Get-Date).AddDays(-1)
Related videos on Youtube
![Zigmaphi](https://i.stack.imgur.com/0G9bW.jpg?s=256&g=1)
Author by
Zigmaphi
Updated on September 18, 2022Comments
-
Zigmaphi almost 2 years
I'm trying to create a PowerShell Cmdlet that runs daily and shows me the errors that occured on the previous day.
I can make it show the last 100. Instead I'd like to see just the one that occured the day before.
get-eventlog -logname application -newest 100 | select eventid,machinename,entrytype,message,source,timegenerated,username | export-clixml C:\Logs.xml
-
ChrisInEdmonton over 10 yearsThe instructions for get-eventlog are available at technet.microsoft.com/en-us/library/hh849834.aspx and fully answer your question.
-
Colyn1337 over 10 yearsWhich one do you want it to show?
-
Zigmaphi over 10 yearsthe event for the day @ChrisInEdmonton i want it to get within a time period of 1 day. i'd previously that article and it didn't help.
-