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)

Share:
16,125

Related videos on Youtube

Zigmaphi
Author by

Zigmaphi

Updated on September 18, 2022

Comments

  • Zigmaphi
    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
      ChrisInEdmonton over 10 years
      The instructions for get-eventlog are available at technet.microsoft.com/en-us/library/hh849834.aspx and fully answer your question.
    • Colyn1337
      Colyn1337 over 10 years
      Which one do you want it to show?
    • Zigmaphi
      Zigmaphi over 10 years
      the 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.