Solved

Windows Event Logs

Posted on 2013-11-16
4
400 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
  • 2
  • 2
4 Comments
 
LVL 39

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 39

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
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…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now