Solved

powershell script help

Posted on 2014-10-31
3
119 Views
Last Modified: 2014-10-31
I found a wonderful report online that emails me a daily report of all of my servers. Currently the report will show me the last 10 Errors and Warnings from the System event log for each server.

I would like this report to only show me these events (if any) from the last 24 hrs... but I have no idea how to edit the script to do so.

Can someone help me out?
SystemReport.txt
0
Comment
Question by:ashleyandy
[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
3 Comments
 
LVL 16

Expert Comment

by:Rajitha Chimmani
ID: 40416157
Find attached the modified script. This will allow you to pull the list for last 24 hours. You can also modify the script to number of hours you would like to go back by changing the the value at the below line in the code.

[int]$Hours = 24
SystemReportHours.txt
0
 
LVL 29

Assisted Solution

by:becraig
becraig earned 250 total points
ID: 40416163
Make the following changes in lines 184 & 199 :


	$SystemEvents = Get-EventLog -ComputerName $computer -LogName System -EntryType Error, Warning -After (Get-Date).AddDays(-1)

Open in new window


	$ApplicationEvents = Get-EventLog -ComputerName $computer -LogName Application -EntryType Error, Warning -After (Get-Date).AddDays(-1)

Open in new window



We're making the change to look for one day back:
-After (Get-Date).AddDays(-1)

Open in new window

0
 
LVL 16

Accepted Solution

by:
Rajitha Chimmani earned 250 total points
ID: 40416171
I missed something in my last attachment. Here is the final one.
SystemReportHours.txt
0

Featured Post

Industry Leaders: 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 previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

628 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