Solved

powershell script help

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
Synchronize a new Active Directory domain with an existing Office 365 tenant
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now