13 Dec 2007 @ 12:27 AM 
 

PowerShell Script for Remote Event Log Viewing

 

I had an issue today where I needed to find the frequency of an error on some of my VMs. It seems like I get VMSCSI errors at the same time each which (which probably means high SAN activity, but I’m trying to nail everything down). Either way, I needed to check all of my event logs for EventID 11 and 15. It’s slow…and by slow I mean it took about 30 minutes to scan 10 or so VMs…but it works, and I was able to get a decent idea of the times I’m seeing these errors.


$servers = .\getservernames.ps1 Tom 

foreach ($server in $servers)
{
     if ((get-wmiobject -computer $server win32_computersystem).manufacturer -eq "VMware, Inc.")
     {
         get-wmiobject -query
            "select * from Win32_NTLogEvent where LogFile = 'System' AND EventCode = 11
            OR EventCode = 15" |
            foreach { add-content c:\temp\$server.log "$_.timegenerated - $_.eventcode" }
     }
}

Aaaand, it’ll return logs for each server, with a time stamp, the event ID, and nothing more. Quick, dirty, but took me 5 minutes and got the info I needed…30 minutes later :p There’s probably a better way. I’ll have to see what I can come up with.

Tags Tags: , , , ,
Categories: Microsoft, PowerShell, Server Management
Posted By: Tom
Last Edit: 05 Dec 2008 @ 06 47 PM

E-mailPermalink
 

Responses to this post » (2 Total)

 
  1. dvdor said...
    11:14 pm - December 17th, 2008

    what are the contents of .\getservernames.ps1 ?

  2. Tom said...
    2:02 pm - December 18th, 2008

    Looks like I neglected to post it. Here it is:

    http://www.phishthis.com/2008/12/18/get-servernamesps1-return-a-list-of-computer-objects-from-active-directory/

 

Leave A Comment ...

 

 XHTML:
You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
\/ More Options ...
Change Theme...
  • Users » 2
  • Posts/Pages » 22
  • Comments » 20
Change Theme...
  • VoidVoid
  • LifeLife « Default
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LiteLight
  • No Child Pages.