Skip to content


VMware vSphere Health Check Report v5.x Installation and Setup

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.txtVMware-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.

Posted in CLI, Datastores, ESX Host, Tools, vCenter.

Tagged with , , , , , , , , , .


89 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. VMwareFan says

    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 = “vmwarereport@faa.gov”
    $msg.To.Add(“pn@blah.blah”)
    $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

  2. Tom says

    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??

  3. Wes says

    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

  4. Pablo says

    Hi all,
    my 5 cents about using the vSphere Health Check Report V5.x in Windows

    In my scenario (Windows XP desktop system, ESXi 4.1 U1), to be able to run the Health Check script (generate the nice html report), i had to install the Vmware Vsphere CLI 4.1 too.

    If i don’t install CLI, a suitable perl installation isn’t installed.

    Regards,
    Pablo.

  5. Wes says

    Thank you Pablo for the response. At the beginning of the article I listed the items you would need. That item should be linked under “PowerCLI” which should then take you to the download for the cli for VMware. Please let me know if that is not what you are referring to.

    Thanks,

    Wes

  6. Pablo says

    Hi,
    thank you for you reply.

    You said the vSphere CLI item should be available under the PowerCLI download link, right? But it isn’t.

    If you check the PowerCLI page (http://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli?ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a), you won’t see any vSphere CLI link download

    Additionally, if the PowerCLI requeriments are checked (http://www.vmware.com/support/developer/PowerCLI/PowerCLI501/powercli501-581491-releasenotes.html#about), CLI isn’t a requirement

    Regards,
    Pablo

  7. Pablo says

    Hi Wess,
    I’m checking some documentation/information, and the vSphere Health Check Report needs the vSphere SDK for Perl that is included in the vSphere CLI installer (http://www.vmware.com/support/developer/vcli/vcli41/vsp4_41_vcli_relnotes.html#about)

    I’m a newbie in the vSphere PowerCLI/CLI/Powershell matters, maybe i’m wrong 🙂

    IMHO, the PowerCLI isn’t needed just to run manually the vSphere Health Check Report perl script.

    Regards,
    Pablo

  8. Wes says

    Thanks Pablo!

    PowerCLI may not be needed. I honestly would have to break out a test environment from scratch to double check. When I built this step by step instructions I had already installed everything and went over it. Then I went back and traced my steps for blog outline. A few of my steps probably have been overlooked. The end result will be the same and everything should work as planned. I really do appreciate your feedback and will change this once I have proven to be true. Please, let me know if you find any other discrepancies.

    -Wes

  9. Kris says

    I just re-installed my OS and re-installed all the latest versions to create the reports. I am using Windows 7 Ultimate x64.

    VMWare vSphere PowerCLI 5.0.1
    Windows 7 embedded Powershell

    I had to install ActivePerl 5.14.2 Build 1402 (64-bit) for the Perl install.

    I am able to get to the vCenter server via VI client and ssh. BUT, I get the following errors early on. Any assistance would be appreciated.

    PS C:\scripts> & ‘.\VMWare Health Check.ps1’
    Can’t locate VMware/VIRuntime.pm in @INC (@INC contains: C:/Perl64/site/lib C:/Perl64/lib .) at C:\Sc
    HealthCheck.pl line 43.
    BEGIN failed–compilation aborted at C:\Scripts\vmwarevSphereHealthCheck.pl line 43.
    Get-Process : Cannot find a process with the name “perl”. Verify the process name and call the cmdlet
    At C:\scripts\VMWare Health Check.ps1:3 char:18
    + $pp = get-process <<<< perl
    + CategoryInfo : ObjectNotFound: (perl:String) [Get-Process], ProcessCommandException
    + FullyQualifiedErrorId : NoProcessFoundForGivenName,Microsoft.PowerShell.Commands.GetProcessComm

    You cannot call a method on a null-valued expression.
    At C:\scripts\VMWare Health Check.ps1:4 char:16
    + $pp.waitforexit <<<< ()
    + CategoryInfo : InvalidOperation: (waitforexit:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    New-Object : Exception calling ".ctor" with "1" argument(s): "Could not find file 'C:\Reports\vmware_
    16.html'."
    At C:\scripts\VMWare Health Check.ps1:8 char:18
    + $att = new-object <<<< Net.Mail.Attachment($file)
    + CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjec

    Exception calling "Add" with "1" argument(s): "Value cannot be null.
    Parameter name: item"
    At C:\scripts\VMWare Health Check.ps1:14 char:21
    + $msg.Attachments.Add <<<< ($att)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

    Exception calling "Send" with "1" argument(s): "Failure sending mail."
    At C:\scripts\VMWare Health Check.ps1:15 char:11
    + $smtp.Send <<<< ($msg)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

    You cannot call a method on a null-valued expression.
    At C:\scripts\VMWare Health Check.ps1:16 char:13
    + $att.Dispose <<<< ()
    + CategoryInfo : InvalidOperation: (Dispose:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

  10. Wes says

    Have you tried to run it manually from cli? What is the result?
    C:\scripts\vmwarevSphereHealthCheck.pl –server vCenterServerName –username administrator –password localadminpass –type datacenter –datacenter “DataCenterName” –report C:\scripts

  11. MJ says

    Dear Wes,

    I tried it running manually from cli but the powershell window opens and close within 2-3 seconds. I am not even able to see the error i am getting. Did you come across such problem?

    Thanks

  12. Wes says

    Yes, usually this occurs when you don’t have the ActivePearl or PowerCLI installed.

  13. Mike van says

    You might want to update the requirements (PowerCLI , Powershell , Report.txt) to include VMware-vSphere-Perl-SDK.

  14. Kirk Bellmore says

    Excellent script, worked perfect first time thru. Thanks for your effort!

  15. Wes says

    Thanks Kirk!

  16. Zach says

    Hi Wes,

    Wondering if you can help with the below error:
    New-Object : Exception calling “.ctor” with “1” argument(s): “Could not find file ‘C:\scripts\vmware_health_check201211
    22.html’.”
    At C:\scripts\report.ps1:8 char:18
    + $att = new-object <<<< Net.Mail.Attachment($file)
    + CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

    Exception calling "Add" with "1" argument(s): "Value cannot be null.
    Parameter name: item"
    At C:\scripts\report.ps1:14 char:21
    + $msg.Attachments.Add <<<< ($att)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

    You cannot call a method on a null-valued expression.
    At C:\scripts\report.ps1:16 char:13
    + $att.Dispose <<<< ()
    + CategoryInfo : InvalidOperation: (Dispose:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    Remove-Item : Cannot find path 'C:\scripts\vmware_health_check20121122.html' because it does not exist.
    At C:\scripts\report.ps1:17 char:12
    + Remove-Item <<<< C:\scripts\vmware_health_check$dt.html
    + CategoryInfo : ObjectNotFound: (C:\scripts\vmwa…ck20121122.html:String) [Remove-Item], ItemNotFoundEx
    ception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

    Many thanks!

  17. Wes says

    Zack, so sorry for the late response. I would start by trying to get the report to generate by itself. If you read through the comments you should see where I have posted in the past about getting it working before scripting and emailing. Let me know if you can get the report to work, and let’s start from there.

    -Wes

  18. kwoolard says

    Hi Wes,

    I have the exact same error messages as ZAC… Though the script runs and generates the html file and emails as an attachment.. However the html file contains no data.. as per the reply from Tom (march 8 2012)..

  19. Pankaj says

    Hi Wes
    I get belove error when I tested against my vSphere 5 environemnt ,but works fine on vShepre 4 .
    I have tried reinstalling the vCLI Perl SDK noluck

    New-Object : Exception calling “.ctor” with “1” argument(s): “Could not find fi
    le ‘C:\scripts\vmware_health_check20130208.html’.”
    At C:\scripts\report2.ps1:8 char:18
    + $att = new-object <<<< Net.Mail.Attachment($file)
    + CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvoca
    tionException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.Power
    Shell.Commands.NewObjectCommand

    Exception calling "Add" with "1" argument(s): "Value cannot be null.
    Parameter name: item"
    At C:\scripts\report2.ps1:14 char:21
    + $msg.Attachments.Add <<<< ($att)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

    You cannot call a method on a null-valued expression.
    At C:\scripts\report2.ps1:16 char:13
    + $att.Dispose <<<< ()
    + CategoryInfo : InvalidOperation: (Dispose:String) [], RuntimeEx
    ception
    + FullyQualifiedErrorId : InvokeMethodOnNull

    Remove-Item : Cannot find path 'C:\scripts\vmware_health_check20130208.html' be
    cause it does not exist.
    At C:\scripts\report2.ps1:17 char:12
    + Remove-Item <<<

  20. Wes says

    Sorry, as I have been swamped. I have not used the script in some time. Let me do some further testing now that I am back in the game and get back with you. Thank you for explaining this for me very clearly.

  21. lighty says

    Hi Wes,

    Although not new to VMware I am new to scripting. I have a Windows 2008 (64bit) machine for my vCenter server. Esxi V5 running my virtual environment and running into problems trying to use the healthcheck script from my vCenter server.

    I have followed the instructions above and have the following installed:
    Powershell,
    PowerCLI
    vSphere Perl SDK
    Active Perl
    on the vCenter server

    When I run the powershell script i get a dos window appear with a load of red errors and disappear before I can read them. A mail is sent but with no report attached.

    I have tried running the vmwarevSphereHealthCheck.pl script manually with both the following datacenter and vcenter types each time I get a blank dos box and then nothing.

    What am i doing wrong? Any help will be gratefully received.

    Many thanks in advance

  22. Wes says

    You may want to run open up the vSphere Perl PowerCLI manually the first time. You have to suppress the confirmation before you will return any results. A guide can be found here.

    Sorry for the late response. Please let me know if that works.

  23. Ken S says

    Hi everyone,

    After giving a few more tries on permissions and CLI errors, I’m now able to get the HTML report to generate. However, when looking at the report the first two tabs (System Summary and vCenter settings) populate fine, however Datacenter, Hosts, and VM’s are empty. I’m not seeing any errors anywhere, has anyone else seen this issue? I’m using the admin account so would not think it would be a permissions issue.

    Thanks in advance!

  24. Ken S says

    I read a bit more into the script itself and just had to change –type datacenter to –type vcenter and remove the datacenter name.

    Bingo!
    Thanks a lot for this script!

  25. Wes says

    Bart,

    I have never seen this message before. Are you adding the “perl” cmd before directory to the script? If so, then you do not need that added.

    -Wes

  26. Wes says

    Bart,
    Check and make sure you have set the powercli execution policy to remotesigned?
    http://blogs.vmware.com/vipowershell/2011/06/back-to-basics-part-1-installing-powercli.html

    Also, I noticed that you are adding something after “-report”. You only need to fill in what is quoted.

    C:\scripts\vmwarevSphereHealthCheck.pl –server “vCenterServerName” –username “administrator” –password “localadminpass” –type “datacenter” –datacenter “DataCenterName” –report

  27. McFlurry says

    Hello,

    i have esxi 5.1 (build 1117900) and vcenter 5.1 running on a win2k8r2 host. Downloaded & installed powercli 5.1 (VMware-PowerCLI-5.1.0-793510.exe) + VMware vSphere SDK for Perl 5.1 (VMware-vSphere-Perl-SDK-5.1.0-780721.exe). I set the execution policy to unrestricted.

    When i open powercli from the desktop, movin to the c:\scripts folder and startin the script usin “.\report.ps1” the powershell windows appears and dissapears within a few seconds and moves around the desktop. Its not possible to see an error description or sth. This movin window only stopps when im able to strike the “x” of the window (which is not quite easy). Ive tried to start the script manually usin vspherehealthcheckscript.pl but still the same – so i guess it has sth to do with missing installation parts of perl or powercli ?

    Im just wondering because i have exact the same config & installation in another environment with the only difference that the vcenter is installed on w2012 – and there i dont have any problems.

    Anyone knows about that ? Am i missing sth. ?

  28. pravanshri says

    Script works great for me. I have also converted the report.ps1 to exe, so that the password is not exposed.

    Did anyone tried to query the standalone esx with virtual machines? Please let me know how to do… It is actually working but not listing the virtual machines of standalone.

  29. Mohamed says

    if I want to send the report to multiple email addresses, what I should add ?
    I tried many format with no luck !!

    can you help ?

  30. Jay says

    Just use multiple $msg.To.Add(“emailaddres@email”) before sending the email and that should cover it

  31. Miki says

    Hi,

    Thanks a lot for the script! This is exactly what I am looking for.
    Is there a way to make the script prompt for password instead of hardcoding it in the script?

    Thanks,
    Valmiki

  32. wonderworld_highway says

    I struggled and finally got this solution ..
    ./vmwarevSphereHealthCheck.pl –server “vcenter server_name” –username “domain\username” –password “password” –type vcenter

  33. Sahil says

    I tried it running manually from cli but the powershell window opens and close within 2-3 seconds. I am not even able to see the error i am getting. Did you come across such problem? Already installed Active perl, power cli, powershell, VMware-vSphere-Perl-SDK

1 2

Continuing the Discussion

  1. Giới thiệu các công cụ monitoring hệ thống VMware vSphere linked to this post on February 24, 2012

    […] và tham khảo hướng dẫn cài đặt và sử dụng script này tại links : VMware vSphere Health Check Report v5.x Installation and Setup | My VM Land VMware Communities: VMware vSphere Health Check Report v5.0.2 Trả lời ngay […]

  2. Giới thiệu các công cụ monitoring hệ thống VMware vSphere - Máy chủ giá rẻ linked to this post on April 1, 2012

    […] Download và tham khảo hướng dẫn cài đặt và sử dụng script này tại links : VMware vSphere Health Check Report v5.x Installation and Setup | My VM Land VMware Communities: VMware vSphere Health Check Report v5.0.2 __________________ MÁY CHỦ […]

  3. Giới thiệu các công cụ monitoring hệ thống VMware vSphere - Diễn đàn Hội Tụ Số linked to this post on June 14, 2012

    […] image Download và tham khảo hướng dẫn cài đặt và sử dụng script này tại links : VMware vSphere Health Check Report v5.x Installation and Setup | My VM Land VMware Communities: VMware vSphere Health Check Report v5.0.2 Theo hoituso.net Xem thêm […]

  4. Performing VMware Health Check linked to this post on February 13, 2013

    […] tweaking. VMware Communities: VMware vSphere Health Check Report v5.0.2 With instructions. VMware vSphere Health Check Report v5.x Installation and Setup | My VM Land I think it may be the next version of what blargoe is referencing. Or the daily report vCheck. Not […]



Some HTML is OK

or, reply to this post via trackback.

*