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
$pp.waitforexit()
$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 = “vmwarereport@yourcompany.com”
$msg.To.Add(“youremailaddresses”)
$msg.Subject = “Today’s VMWare Health Report”
$msg.Body = “Enjoy from myvmland.com!”
$msg.Attachments.Add($att)
$smtp.Send($msg)
$att.Dispose()
Remove-Item C:\scripts\vmware_health_check$dt.html
– 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.
Hello
I am a newbie to VMware and currently still supporting vSphere 4.0 environment.
I have been long waiting for a useful script like this one to ease the task a bit.
so I pretty much follow your step-by-step instructions above, but can’t get the script to run correctly and so frustrated not knowing what I did wrong. the only thing I receive is an email generated. I would really appreciated if you can help me out here.
here is the Reports.ps1 script that I tried to run it remotely from my machine which has full access to this vCenter box. (all my other scripts works fine)
(healthCheck.conf and .pl script are left alone untouched as instructed)
$dt = get-date -format yyyyMMdd
C:\scripts\vmwarevSphereHealthCheck.pl –server XXXXXX –username XXXXXX –password XXXXXX –type vcenter –report C:\Reports\vmware_health_check$dt.html -email yes
$pp = get-process perl
$pp.waitforexit()
$file = “C:\scripts\vmware_health_check$dt.html”
$smtpServer = “relay.faa.gov”
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($file)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = “[email protected]”
$msg.To.Add(“[email protected]”)
$msg.Subject = “Today’s VMWare Health Report”
$msg.Body = “Enjoy from myvmland.com!”
$msg.Attachments.Add($att)
$smtp.Send($msg)
$att.Dispose()
Remove-Item C:\scripts\vmware_health_check$dt.html
I kept getting errors about email when I tried to run the report.ps1 script, so I just ran the “vmwarevSphereHealthCheck.pl” as per your instructions to see if that would work. I get the message saying to get a cup of coffee but that goes away after about 1 second. An .html file gets created in the scripts directly and has the different menu items (“cluster”, “vcenter”, etc) but has no actual content. Any thoughts on what I can do to get this to work??
I’ve seen this issue before. Make sure you are putting in the *datacenter* name. Sometimes that isn’t clear because it is the root name and could have spaces in it. Also check permissions and run the manual by command line. It should def. take longer than a minute before the “Coffee” window goes away.
C:\scripts\vmwarevSphereHealthCheck.pl –server vCenterServerName –username administrator –password localadminpass –type datacenter –datacenter “DataCenterName” –report C:\scripts
Hope this helps,
Wes