Solved

powershell script help

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Set OWA language and time zone in Exchange for individuals, all users or per database.
"Migrate" an SMTP relay receive connector to a new server using info from an old server.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

821 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