Solved

Windows Event Logs

Posted on 2013-11-16
4
409 Views
Last Modified: 2013-11-17
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.
0
Comment
Question by:CaussyR
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
footech earned 500 total points
ID: 39653684
If I'm understanding your date restrictions right, the below will work.
Get-WinEvent -ComputerName homePC -FilterHashtable @{LogName='Application'; starttime=([datetime]::Today); endtime=([datetime]::Today.AddHours(2)); id=1007} | select MachineName, ID, TimeCreated, Message | fl *

Open in new window

By the way, you can't have the Select-Object command after Format-List and expect to get anything, as the objects output from the Format commands don't include the properties of the objects input to them.  The Format commands should always be the last in the pipeline.
0
 

Author Comment

by:CaussyR
ID: 39654513
Thanks, that's exactly what I was looking for. I couldn't find anything on addhours, how did you find out the additional attributes ?
0
 
LVL 40

Expert Comment

by:footech
ID: 39654840
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
0
 

Author Comment

by:CaussyR
ID: 39655028
Thank you for all your help FooTech.
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question