Solved

powershell script help

Posted on 2014-10-31
3
118 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

Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
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ā€¦

738 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