Trying to display application event logs within a date range using powershell but not working...help needed asap

Hi all,

i am trying below command and it is givng me error please help how i can display the application event logs within a date range

get-eventlog -logname application -after "3/13/12" -before ([datetime]"March 15,2012")

i have tried below also but even below also not working cam someone please help me on this?????

$StartDate = get-date 3/13/12

$EndDate = get-date 3/15/12

get-eventlog -log Application -entrytype Error -after $StartDate -before $EndDate

Thanks in Advanc

March 15th, 2012 9:36am

Get-EventLog  -LogName "application" -After 3/10/2012 -Before 3/11/2012 -EntryType "Error"

Try this..
Free Windows Admin Tool Kit Click here and download it now
March 15th, 2012 9:57am

Both commands working fine for me. Can you post error as well? It will help us to undarstand problem.

March 15th, 2012 10:01am

Get-EventLog  -LogName "application" -After 3/10/2012 -Before 3/11/2012 -EntryType "Error"

Free Windows Admin Tool Kit Click here and download it now
March 15th, 2012 10:20am

Both commands working fine for me. Can you post error as well? It will help us to undarstand pr

March 15th, 2012 10:22am

Get-EventLog  -LogName "application" -After 3/10/2012 -Before 3/11/2012 -EntryType "Error"

Free Windows Admin Tool Kit Click here and download it now
March 15th, 2012 10:45am

I missed one point. You need to sort before fetching the last 100.

Get-EventLog  -LogName "application" -After 3/10/2011 -Before 3/11/2012 -EntryType "Error" -Source MSDTC  |Sort-Object timegenerated |Select-Object -Last 100

March 15th, 2012 10:52am

Get-EventLog  -LogName "application" -After 3/10/2012 -Before 3/11/2012 -EntryType "Error"

Free Windows Admin Tool Kit Click here and download it now
March 15th, 2012 10:54am

Typo :(

Select -last 100

March 15th, 2012 10:57am

Get-EventLog  -LogName "application" -After 3/10/2011 -Before 3/11/2012 -EntryType "Error" -Source MSDTC |select -last 100

Free Windows Admin Tool Kit Click here and download it now
March 15th, 2012 10:59am

Get-EventLog  -LogName "application" -After 3/10/2011 -Before 3/11/2012 -EntryType "Error" -Source MSDTC |select -last 100		
March 15th, 2012 11:16am

Try this way:

Get-EventLog  -LogName "application" -After 3/10/2011 -Before 3/11/2012 -EntryType "Error" -Source "*SQL*" |select -last 100

Free Windows Admin Tool Kit Click here and download it now
March 15th, 2012 11:26am

You can try out as Bhavik mentioned.

-Source "*SQL*"

Good luck !

March 15th, 2012 11:48am

You can try out as Bhavik mentioned.

-Source "*SQL*"

Good

Free Windows Admin Tool Kit Click here and download it now
March 15th, 2012 12:27pm

Try it from your laptop with -computername switch.

You should run this with an account having permission on the server.

Get-EventLog -ComputerName "Servername"  -LogName "application" -After 3/10/2011 -Before 3/11/2012 -EntryType "Error" -Source "*SQL*" |select -last 100


March 15th, 2012 12:30pm

Try it from your laptop with -computername switch.

You should run this with an account having permission on the server.

Get-EventLog -ComputerName "Servername"  -LogName "application" -After 3/10/2011 -Before 3/11/2012 -EntryType "Error" -Source "*SQL*" |select -last 100

Free Windows Admin Tool Kit Click here and download it now
March 15th, 2012 12:37pm

What is the error message you are getting when you run your script?
March 16th, 2012 8:15am

How about for just the past hour?

I have been trying to script in PowerShell to obtain a specific EventID for the last hour and export to a file (file type of text or csv).

Been tring to set two variables for BeginTime = (Get-Date).hour-1 but then need to format as hh:00:00

Then an EndTime  = (Get-Date).hour-1 formatted as hh:59:59

Thanks for looking.

Free Windows Admin Tool Kit Click here and download it now
July 8th, 2013 9:44am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics