The Multifunctioning DBA

Sep 19 2011   10:00AM GMT

SQL Server Health Check Follow Up

Colin Smith Colin Smith Profile: Colin Smith

A long while ago I wrote a script that does a SQL Server Health check and I posted it here. Recently I have gotten some comments on it and I want to help some people out. So I thought I would review it. So it is a script that goes out and connects to sql servers that are defined in a list, actually a csv file, and gathers some information and outputs that data into an Excel sheet. You can modify the script in any way you want to gather any data you want. The script is available in that post.

It seems that the questions are related to reading in the file that holds the instance information. You can see that this is the line that reads in the file.

$servers = Import-Csv "\\ent-pocpacapcx01\d$\monitoring\sqltab.txt"

So you need to make sure that you change that path and file name to where your server file is. Lets go over the block that defines what has been read in so we can define what the csv file needs to look like.

foreach ($entry in $servers)
$torp = $entry.TorP
$mon = $entry.monitor
$machine = $entry.server
$errorlog = $entry.errorlog
$os = $entry.os2000
$iname = $entry.Instance
if ($iname -eq "Null")
$instance = "$machine"
$instance = "$machine\$iname"
$instance = $instance.toupper()

What we can see is that I am looking at everything that the import-csv brought in to the $servers variable. Then I am defining some variables and you may not have all of these in your csv file. but if you look at $entry._____, that ______ is what my header information is. You need to make sure that your CSV file has the header information that you want to have in it. You might not have a errorlog or a TORP header because you may not need them. Just make sure that you modify either your file or this code so that they all match up. Then you should not have issues with the file not reading in correctly. Please let me know if you have any questions. leave me a comment and I will try to respond but you can also hit me up on twitter @smithco32 and I will get back to you.

Thanks and I hope that this helps.

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: