Get Server Warnings and Errors With Powershell


I’m a great fan of Powershell especially when it makes my life easier for all day jobs.

So one day I had to check all our servers if an error or a warning occured. I had to supply the server name and followed by the server name a “V” for checked and good, a “X” for checked errors and an “!” if something went wrong.

This had to be placed in an Excel file.

I  created scripts before that had to ouput data to a CSV file so  this was not new for me.

The script can be used as follows:

As you can see the script uses three variables:

  1. Serverlist: File with the list of Servers
  2. Output: Output directory where the results can be placed
  3. Rows: The amount of rows from the eventlog that need to be searched

The first parameter is a mandatory parameter pointing to the CSV file with the servers. The format how the servers need to be placed in the CSV file is as follows:

The second parameter is not mandatory and is the output directory. If this parameter is not used the script will output the data to the screen.

The third parameters is the amount of rows that need to be searched through. Eventlogs tend to get pretty big which causes the script to become slow. This is why the amount of rows is given. The script will select the newest records untill the amount of rows is reached.

The script will need to have the ping function script that is also included at the bottom of the article.

The output of the script looks as follows:


If you have any comments please feel free to post them!

Leave a Reply