Event Log Morning Report

The Morning Report script I published earlier this yeas was quite popular. One of the changes I made in it was to skip getting event log entries to speed up the overall process. But I received an inquiry today about how to create the report with only event log information. The only way really is to revise the script.

So I did.

Well, actually I wrote a new script based on the last version. This script, EventlogMorningReport.ps1 works basically the same as the regular morning report except it only gets event log information. Although I added a section to also get audit failures from the Security event log. You run it the same way. You might even want to use a background job.


PS E:\> start-job {get-content computers.txt | c:\scripts\EventLogMorningReport.ps1 -verbose -html | out-file E:\temp\evtlog.htm}

I suppose the better approach would have been to modify the Morning Report script and make each of the different sections optional. And perhaps I’ll address that at some point. But time was tight this morning and it was quicker to simply strip out the bits I didn’t need.

The underlying code hasn’t really changed much so I won’t post it. Feel free to download EventLogMorningReport and give it a spin.

New Event Report Revised

Last year I posted an update to an old Mr. Roboto script that was an update to an even older VBScript. Still with me? My last revision leveraged the new Get-WinEvent cmdlet to create an HTML report of recent error activity on one or more computers. The problem was that I didn’t account for older computers that don’t support Get-WinEvent. I finally have a version that does. Continue reading

New Event Report

For a number of years I wrote the popular Mr. Roboto column for REDMOND magazine. When I first started the column, many of my scripts were written in VBScript. Then as PowerShell came along that became the preferred tool. Over time I realized there were some VBScripts that could be rewritten and even improved using PowerShell. One of them was a script that queried event logs on computers for errors and warnings in the last X number of hours and prepared a colorized HTML report. I revised that script to a PowerShell v1 script. Recently, a loyal reader asked about revising the script again for PowerShell 2.0. That seemed reasonable so here is my revision. Continue reading

Friday the 13 Script Blocks

In celebration of Friday the 13th and to help ward off any triskaidekaphobia I thought I’d offer up 13 PowerShell scriptblocks. These are scriptblocks that might solve a legitimate business need like finding how long a server has been running to the more mercurial such as how many hours before I can go home.

A scriptblock is any small piece of PowerShell code enclosed in a set of curly braces. I say small, but there’s really no limit. You can even pass parameters to a script block. In this way they are like functions but without the function key word. Save the script block to a variable and when you want to execute, use the invoke operator, the & character. For example, here’s one of my luck 13 script blocks.
[cc lang=”powershell”]
#1. Get running services
$running={Param ([string]$computername=$env:computername) get-service -computername $computername |
where {$_.status -eq “Running”}}
[/cc]
To invoke it:
[cc lang=”powershell”]
PS C:\> &$running
[/cc]
Because this particular script block takes a computername as a parameter I could also do this:
[cc lang=”powershell”]
PS C:\> &$running Server01
[/cc]
I won’t post the complete script here, but these are the goodies:
#1. Get running services
#2. Get logical disk information
#3. Get day of the year
#4. Get top services by workingset size
#5. Get OS information
#6. Get system uptime
#7. get a random number between 1 and 13
#8. How old are you?
#9. get %TEMP% folder stats
#10. Get event log information
#11. Get local admin password age in days
#12. Get cmdlet summary
#13. How much time before I can go home?

I wrote many of the script blocks so that you could use them in your own functions and scripting and tried to make them re-usable as possible. They have no error handling and assume you have all the necessary permissions. Think of them as quick and dirty PowerShell snippets. The script file is simply defines the 13 script blocks. After each one is a commented example of how you might run it.

Again, I’m not promising anything life-changing but I hope you’ll have fun with them today. Download the script file 13ScriptBlocks.ps1.