Solved

Windows Event Logs

Posted on 2013-11-16
4
407 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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