i have been having dab around powershell and the more you get in to it the better it gets.

as I mentioned in my earlier post, I have got a test lab setup with 5 servers in it and though I can use RSAT tools to get event logs off them but i wanted to kind of make my life easy and automate it a bit so I have been using invoke-command to do so. It just gets better and better.

Here it is :

$compname=Read-Host “Enter Computer Name  ”      <<< this line prompts user to enter a valid computer name and saves it in compname variable
$arraylog=’Application’,’System’,’Security’    <<< this arraylog variable saves some info

write-output $arraylog   <<< and displays it on the screen
$logname=Read-Host “Enter Log Name ”   << user makes a choice

$eventsize=read-host “Enter event number(s)”    <<< this variable eventsize asks to enter number of events returned from the log

$grabit = Get-EventLog -ComputerName $compname -LogName $logname -Newest $eventsize   <<< all variables are passed on to here

write-output $grabit   << result displayed

this is a very basic script which has got no checks etc on it i.e what to enter and what not to but the possibilities are endless with PShell.  May, you can create a basic tool to suite your environment. 😉

People from Unix and Linux background can also dive straight in because the powershell supports the commands.

if you want to learn more about powershell then go to powershell.org or MVA/TechEd.

Finished File (no responsibility accepted for any damage) >> eventLogViewer.ps1_

and you can find the youtube video over here >>> logViewer.ps1_


get-eventlogs _Powershell script

Leave a Reply

Your email address will not be published. Required fields are marked *

Plugin for Social Media by Acurax Wordpress Design Studio
Visit Us On TwitterVisit Us On FacebookVisit Us On Google PlusVisit Us On YoutubeVisit Us On Linkedin