Powershell Event Error Details

I have over 100 Windows servers from Windows 2003 to Windows 2012

We need to review the Event logs and a daily basis. We must use event viewer review the application and system logs.
This takes a while to expand the event log using MMC or Server Manager views.

I be playing around with Powershell scripts to handle this which is faster

So I use this command which lists the application Warnings Only from the last twenty four hours.  
I use Level=2 for Errors also do this for both the application and system event logs.


This outputs see below  and that is ok

 get-winevent -FilterHashTable @{LogName='Application'; Level=3; StartTime=(get-date).addhours(-24)}


TimeCreated                   ProviderName                                             Id Message
-----------                   ------------                                             -- -------
10/2/2015 12:09:26 PM         Microsoft-Windows-Certific...                            64 Certificate for local syst...
10/2/2015 4:09:25 AM          Microsoft-Windows-Certific...                            64 Certificate for local syst...
10/1/2015 8:09:24 PM          Microsoft-Windows-Certific...                            64 Certificate for local syst...

This looks good

My question is how do I display the details of Event Id 64 using power shell

I only want to view the last occurrence I have only been able to get a long list of all instances.

Our management here is not keen on elaborate scripts they like us to use command line so we remember the commands

Every day the events will be different so maybe a short script where I can just add the event id as input would be nice.

Thoughts

Thanks
LVL 23
Thomas GrassiSystems AdministratorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

footechCommented:
What do you mean by "details"?
If you just want the message, use Select-Object.
If you only want event ID 64, include ID in your filterhashtable.
If you want to limit the number of events retrieved, use the -MaxEvents parameter of Get-WinEvent.
0
Thomas GrassiSystems AdministratorAuthor Commented:
footech

thanks for responding


this is what I mean by full details

Log Name:      Application
Source:        Microsoft-SharePoint Products-SharePoint Server Search
Date:          9/6/2015 5:56:41 AM
Event ID:      14
Task Category: Gatherer
Level:         Warning
Keywords:      
User:          xxx\spservices
Computer:      SERV013.FQDN.com
Description:
The start address http://sharepointtgcs.com cannot be crawled.

Context: Application 'Search_Service_Application', Catalog 'Portal_Content'

Details:
      An unrecognized HTTP response was received when attempting to crawl this item. Verify whether the item can be accessed using your browser.   (0x80041204)
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-SharePoint Products-SharePoint Server Search" Guid="{C8263AFE-83A5-448C-878C-1E5F5D1C4252}" />
    <EventID>14</EventID>
    <Version>14</Version>
    <Level>3</Level>
    <Task>137</Task>
    <Opcode>0</Opcode>
    <Keywords>0x4000000000000000</Keywords>
    <TimeCreated SystemTime="2015-09-06T09:56:41.851264900Z" />
    <EventRecordID>57936</EventRecordID>
    <Correlation />
    <Execution ProcessID="1512" ThreadID="9160" />
    <Channel>Application</Channel>
    <Computer>SERV013.FQDN.com</Computer>
    <Security UserID="S-1-5-21-3054588571-1341459584-784128302-4607" />
  </System>
  <EventData>
    <Data Name="string0">http://sharepointtgcs.com</Data>
    <Data Name="string1">

Context: Application 'Search_Service_Application', Catalog 'Portal_Content'

Details:
      An unrecognized HTTP response was received when attempting to crawl this item. Verify whether the item can be accessed using your browser.   (0x80041204)</Data>
  </EventData>
</Event>




so when I get the list of event I would like to run another command to show the entire event message

do you have an example to display the event ?
0
Thomas GrassiSystems AdministratorAuthor Commented:
Footech

tried this

Get-WinEvent -FilterHashtable @{ LogName = "Application"; id = 1001; -maxevents=1}
At line:1 char:68
+ ... nEvent -FilterHashtable @{ LogName = "Application"; id = 1001; -maxev ...
+                                                                  ~
The hash literal was incomplete.
At line:1 char:82
+ ... -FilterHashtable @{ LogName = "Application"; id = 1001; -maxevents=1}
+                                                                         ~
Unexpected token '}' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : IncompleteHashLiteral
0
Top Threats of Q1 & How to Defend Against Them

WEBINAR: Join WatchGuard CTO and our Threat Research Team on Aug. 2nd to hear the findings from our Q1 Internet Security Report! Learn more about the top threats detected in the first quarter and how you can defend your business against them!

footechCommented:
So you want to display all events using the table format, e.g.
TimeCreated                   ProviderName                                             Id Message
-----------                   ------------                                             -- -------
10/2/2015 12:09:26 PM         Microsoft-Windows-Certific...                            64 Certificate for local syst...
10/2/2015 4:09:25 AM          Microsoft-Windows-Certific...                            64 Certificate for local syst...
10/1/2015 8:09:24 PM          Microsoft-Windows-Certific...                            64 Certificate for local syst...

Open in new window

and then you want to display everything for just one of those events?

If so, for that last display, you'd either have to re-do the query, or have saved the previous results so that you can then just display one.  There's no exact equivalent to the view you get in Event Viewer, basically you'd just want to show all properties (think Format-List *).

The -maxevents parameter is not part of the hashtable.
0
Thomas GrassiSystems AdministratorAuthor Commented:
Confused now

Is there a way to display a single event error? And only the last occurrence?

Example please?
0
footechCommented:
Get-WinEvent -FilterHashtable @{ LogName = "Application"; id = 1001} -maxevents 1 | FL *

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Thomas GrassiSystems AdministratorAuthor Commented:
FooTech

That worked and is what I was looking for

Now I am off to setting up the script to except input so I can display any event Id I come across

If I have any issues I ll post another one

Thanks again
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.