Here I am going to show you how to install and configure the vSphere HCR v.5 on the Windows platform. There are a few tools you need before we get started. Go ahead and download them so you will be ready to implement them when the time is ready.
PowerCLI , Powershell , Report.txt, VMware-vSphere-Perl-SDK
vSphere Health Check Report – Please make sure you have the latest copy
*Note* I am going to be installing the version compatible with vSphere and above. If you are currently running ESX(i) 3.5 with update 2 or above, please use VMware Health Check Report v0.9.5
Since vCenter is currently only installable on a Windows platform, this is where I chose to run these scripts from. From here, you can set Task Manager to email you the report on demand. Make sure both Microsoft Powershell (2003 version) and Power CLI on the vCenter server.
If you haven’t done so, go to http://communities.vmware.com/docs/DOC-9842 to download the the latest Health Check script found right before the comments area. Next, create a scripts folder under the C: drive to put the file(s) in.
Extract the contents with any compression executable and place the two files in the scripts folder.
There is no need to edit the heathcheck.conf file since the report.ps1 will automate the email process. Take the downloaded file called Report.txt and stick it in the scripts folder. Rename the the file’s extension to “.ps1”. This will make it readable by PowerCLI.
When you edit the file it will look like the format below.
$dt = get-date -format yyyyMMdd
C:\scripts\vmwarevSphereHealthCheck.pl –server vCenterServerName –username administrator –password localadminpass –type datacenter –datacenter “DataCenterName” –report C:\scripts\vmware_health_check$dt.html -email yes
$pp = get-process perl
$file = “C:\scripts\vmware_health_check$dt.html”
$smtpServer = “YourEmailServerName”
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($file)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = “firstname.lastname@example.org”
$msg.Subject = “Today’s VMWare Health Report”
$msg.Body = “Enjoy from myvmland.com!”
– Edit the information in BOLD so that it matches your organization. I recommend user a user’s password that does not change. Exit the editor and be sure to save the changes.
Now, let’s test the script to make sure there are no error. Open up vSphere PowerCLI – Then browse to the scripts directory and execute the script.
If all goes well, you will have a message from the scripts creator (William Lam) telling you to get a cup of coffee/tea and check out his website. This can take a while, as mine took over 5 minutes to finally email me.
The next step is to set windows to auto run the script so you don’t have to manage that. Anything that helps automate this process so you can just stick to watching your environment.
Open up Scheduled Tasked under the Start Menu and create a new task by clicking “Add Scheduled Task”. Browse your Applications till you find VMware vSphere Power CLI and click next. Choose the method of time frame and click next. From there you need to enter a user name and password that will not be changing. I would suggest using the local administrator account. Finish and open up the advanced settings for this task. Copy and paste the below information
Insert this into the Run: “C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile “C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vim.psc1″ ” & “C:\Scripts\report.ps1″
Click the apply and give it a test run. That should be all the modifications you will need to finish the automation. Please let me know if this information has been helpful or needs any updates.
If you have any problems running the script then open up PowerCLI from the Start Menu Programs. Browse to the scripts folder and test to make sure its working with this command:
./ vmwarevSphereHealthCheck.pl –server vCenterServerName –username administrator –password localadminpass –type datacenter –datacenter “DataCenterName” –report C:\scripts\vmware_health_check$dt.html
Please leave some feedback on anything you would like to see or added to this post.