Link to home
Start Free TrialLog in
Avatar of CaussyR
CaussyR

asked on

Windows Event Logs

Hi everyone,

I am trying to return events in the Application log from 00:01 to 02:00 on the same day I run the script below :

Get-WinEvent -ComputerName homePC -FilterHashtable @{LogName='application'; starttime=([datetime]::today.AddDays(-1)); endtime=([datetime]::Today); id=1007} | format-list * | select MachineName, ID, TimeCreated, Message

The problem I have is I can only get the last 24 hours rather than running the script on the same days and only list the event id:1007 in the past 24 hours rather than just between 00:00 and 02:00.

Can anyone help, please.
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CaussyR
CaussyR

ASKER

Thanks, that's exactly what I was looking for. I couldn't find anything on addhours, how did you find out the additional attributes ?
Not sure if I read about it first, or just saw it as an available method for datetime objects (it's been a while).  You can use Get-Member to see the properties and methods for an object.  Here's a couple examples.
[datetime]::now | gm
get-date | gm

In the first example, a static property is also used.  A static method or property is referenced by the type, then a double colon, followed by the property or method.  You can see what static methods and properties are available with something like the following.
get-date | gm -static
Avatar of CaussyR

ASKER

Thank you for all your help FooTech.